I am currently trying to make a Token-Based auth between a NodeJS server and AngularJS client.
In other words: Server generates token, sends to client in http header, client receives and sets that token to be sent in the next request (in the http header), when the request gets to the server it's checked if it contains a previously sent token. Repeat.
The problem is I'm not able to read the headers from AngularJS, even though I can see the header was successfully set in the response, through Chrome's console.
So far, I've got an AngularJS interceptor (What I've been told I should do) like this:
angular
.module('injector', [])
.factory('sessionInjector', function(){
var injectedSession = {
response: function(res) {
console.log("RESPONSE: " + JSON.stringify(res.config.headers));
return res;
};
return injectedSession;
});
And this is the output:
RESPONSE: {"Accept":"application/json, text/plain, */*"}
I've just started with AngularJS and I'm a little lost. Hope I didn't mess up something really basic.
Thank you.