I implemented JWT on my angular js application . I added the jwt authorization keys with all the http function . My codes are :
angular.module('IttadishopServices', [])
.config(function Config($httpProvider, jwtInterceptorProvider) {
jwtInterceptorProvider.tokenGetter = function (User) {
var jwt = localStorage.getItem('id_token');
if (localStorage.getItem("id_token") === null) {
User.generateToken().success(function (data) {
localStorage.setItem('id_token', data);
return data;
});
} else {
return jwt;
}
}
$httpProvider.interceptors.push('jwtInterceptor');
});
Now Problem is , the authorization key is added on the header . but each request is send double to the server . I tried to add that authorization key many ways , but every time each request is sending double to the server , one request with the authorization key and another without any authorization key . Added an screenshot of console .