0
ここでインターセプタ。トークンはうまく見えますが、クロムデバッガのリクエストヘッダーを確認するとヘッダーはまだ空です。インターセプタのJWT認証ヘッダーを設定していません
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);
私は一体何が問題であるかを把握カント...たぶん私は盲目:-)
あなたはインターセプタ配列(したがって、それを登録する)にそれを追加しました:ちょうどアプリで私のサーブレットフィルタを強化 - 私の場合は
は私も有効にCORSが同じクラスでこれをやりましたか? – AranS
はい、私はしました。また、クロムデバッガがこのコードにジャンプします。 –
承認ヘッダにブレークポイントを設定すると、「Bearer + yourToken」が表示されますか? – AranS