user3703539
user3703539

Reputation: 437

angular-jwt no token in header

I use angular-jwt angular-jwt": "^0.1.5", i check the documentation but it's not work.

This is in my app.js, token is set and get :

.config(function Config($httpProvider, jwtOptionsProvider) {
$httpProvider.interceptors.push('jwtInterceptor');
jwtOptionsProvider.config({
  whiteListedDomains: ['http://localhost:8080/', 'localhost'],
  tokenGetter: function(options, jwtHelper) {
    var token = window.localStorage.getItem('token');
    return token;
  }
});

})

I can't find header authorizaton in my request :

{ host: '172.18.17.155:8080',
  connection: 'keep-alive',
  accept: 'application/json, text/plain, */*',
  origin: 'http://localhost:8100',
  'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36',
  referer: 'http://localhost:8100/',
  'accept-encoding': 'gzip, deflate, sdch',
  'accept-language': 'fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4' }

I forgot or not understand something ? I need to pass header in my request manually ?

Upvotes: 2

Views: 1489

Answers (1)

Jonas Ribeiro
Jonas Ribeiro

Reputation: 306

You did not define whiteListedDomains correctly, actually you should set your host value property:

Ex: whiteListedDomains: ['172.18.17.155']

.config(function Config($httpProvider, jwtOptionsProvider) {
$httpProvider.interceptors.push('jwtInterceptor');
jwtOptionsProvider.config({
  whiteListedDomains: ['172.18.17.155'],
  tokenGetter: function(options, jwtHelper) {
    var token = window.localStorage.getItem('token');
    return token;
  }
});

Upvotes: 2

Related Questions