auth0 / angular2-jwt

Helper library for handling JWTs in Angular apps
MIT License
2.63k stars 485 forks source link

Authoritation header is not added no request. #556

Closed konum closed 6 years ago

konum commented 6 years ago

The interceptor kicks in correctly and gets to jwt.interceptor.js, the lines that are supposed to set the header. Despite this the http requests dons't get the Authoritation header.

app.module.ts

import { JwtModule } from '@auth0/angular-jwt';

export function tokenGetter() {
  return localStorage.getItem('token');
}

imports:
....
JwtModule.forRoot({
      config: {
        tokenGetter: tokenGetter,
        whitelistedDomains: ['localhost:8080'],
        blacklistedRoutes: ['localhost:8080/public/user/login']
      }
    }),
....
"dependencies": {
    "@angular/animations": "6.0.9",
    "@angular/cdk": "^6.4.1",
    "@angular/common": "6.0.9",
    "@angular/compiler": "6.0.9",
    "@angular/core": "6.0.9",
    "@angular/forms": "6.0.9",
    "@angular/http": "6.0.9",
    "@angular/material": "^6.4.1",
    "@angular/platform-browser": "6.0.9",
    "@angular/platform-browser-dynamic": "6.0.9",
    "@angular/platform-server": "6.0.9",
    "@angular/router": "6.0.9",
    "@auth0/angular-jwt": "^2.0.0",
    "ajv": "6.4.0",
    "arrive": "2.4.1",
    "bootstrap": "4.1.0",
    "bootstrap-material-design": "4.1.1",
    "bootstrap-notify": "3.1.3",
    "chartist": "0.11.0",
    "classlist.js": "1.1.20150312",
    "core-js": "2.4.1",
    "googleapis": "28.1.0",
    "hammerjs": "2.0.8",
    "jquery": "3.2.1",
    "moment": "2.18.1",
    "ngx-toastr": "^8.10.0",
    "node-sass": "^4.9.2",
    "npm": "^5.10.0",
    "perfect-scrollbar": "1.1.0",
    "popper.js": "1.14.3",
    "rxjs": "6.2.2",
    "rxjs-compat": "^6.2.2",
    "web-animations-js": "2.3.1",
    "zone.js": "0.8.26"
  }
konum commented 6 years ago

No angular2-jwt related. The server had secured OPTIONS call so I was getting Response for preflight has invalid HTTP status code. Sorry for the incovinience.