Ionic App Not Sending Authorization Header. The Header Values Are Simply Not There Even though the Authorization Header Is Listed Among The Allowed Headers. I Am Using NodeJS Express And MongoDB as A Backend Here Are My CORS Headers
<code>
res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods',
'GET,PUT,POST,DELETE,OPTIONS');
res.header('Access-Control-Expose-Headers',
'X-Authorization-Token, Authorization');
res.header('Access-Control-Allow-Headers',
'Origin, X-Requested-With, Content-Type, Accept, Authorization'
);
And Here Is My AuthInterceptor
return {
request: function(config) {
var token = authToken.getToken();
if (token) {
config.headers.Authorization = 'Bearer ' + token;
}
return config;
},
response: function(response) {
return response;
}
};
My $http
return $http(options).success(function(response) {
self.currUser = response.profile;
if (_.contains(response.profile.roles, 'admin') ||
!((_.contains(response.profile.roles, 'lecturer')) || (_.contains(
response.profile.roles, 'evaluator')))) {
$state.go('admin');
}
})
</code>
authToken.getToken()synchronous? Does it return a valid token? If it is asynchronous you have a problem