here the interceptor. The token looks good to me but the header is still empty when i review the request header in chrome debugger.
function httpInterceptor($q, $rootScope, $location, $localStorage) {
return {
'request': function(config) {
if ($localStorage.authToken) {
config.headers.Authorization = 'Bearer ' + $localStorage.authToken; // SET HEADER HERE!!!
}
console.debug('intercepting request to url: ' + config.url);
return config;
},
'response': function(response) {
console.debug('intercepting response');
return response;
},
'responseError': function(response) {
console.debug('intercepting response error');
if (response.status === 401 && $location.path().indexOf('login') == -1) {
console.debug('authentification required redirecting to login page.');
response.data = '';
if ($location.path().indexOf('login') == -1) {
$rootScope.preLoginUrl = $location.path();
}
$location.path('/login');
return {};
} else {
console.debug(response.config.method + ' on ' + response.config.url + ' failed with status ' + response.status);
}
return $q.reject(response);
}
};
}
angular.module('hop').service('httpInterceptor', httpInterceptor);
I cant figure out what the heck is the problem...maybe i am blind :-)