question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JWT Interceptor does not attach header to the request (prod)

See original GitHub issue

Hi,

I use the version 2.0.0 with angular 6, but the JWT Interceptor does not attach header to the request, but this only occurs by executing the ng serve --prod or ng build --prod, generated in development mode it works without problems.

My configuration is as follows:

`export function tokenGetter () {    return localStorage.getItem (‘token’); }

const jwtConf: JwtModule = {    config: {      tokenGetter: tokenGetter,      whitelistedDomains: environment.tokenWhitelistedDomains,      blacklistedRoutes: environment.tokenBlacklistedRoutes    } }

@NgModule ({    imports:      FormsModule,      CommonModule,      JwtModule.forRoot (jwtConf),      SecurityRoutingModule    ]`

And the enviroments:

`export const environment = {    production: true,    origin: ‘http://localhost:8080/api/’,

tokenWhitelistedDomains: [‘localhost: 8080’],    tokenBlacklistedRoutes: [new RegExp (‘\ /oauth/token’)] };`

I have tried in many ways, but without success.

Thank you.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
ghostcommented, Dec 1, 2018

I had the same problem fixed it by changing the environments

tokenWhitelistedDomains: ['localhost:8080'],
  tokenBlacklistedRoutes: ['localhost:8080\/oauth\/token']
1reaction
stevehobbsdevcommented, Aug 6, 2019

Thanks @willianfalbo, we will be adding this to the documentation so that people don’t hit this problem in the future, as per #593

Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting JWT Authorization Header in Interceptor not working
In my case the UI app runs on a different server/domain as the backend rest services. Whenever the UI now tries to request...
Read more >
HTTP Interceptor to Set Auth Header for API Requests if User ...
The JWT Interceptor intercepts HTTP requests from the application to add a JWT auth token to the HTTP Authorization header if the user...
Read more >
Top 10 ways to use Interceptors in Angular - Medium
My ten favorite ways to use the interceptor in Angular. With examples of error handling, profiling, caching and more this list will inspire...
Read more >
Angular Interceptors to Manage HTTP Requests
Learn how to use Angular interceptors to manage HTTP requests including JWT authorization , caching and logging.
Read more >
CWTAI - IBM
CWTAI0009E: Trust Association Interceptor configuration is not valid. ... token in the authorization header of the http request but the token is incorrectly ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found