Open intankirana19 opened 4 years ago
I just found out why it happened because I need to put the token on cookies too, how do I do this? On postman the token I put on header authorization automatically set on cookies thats why the API works
In my case, I used:
token: { class: NbAuthSimpleToken, key: 'access_token', },
The token should put on header authorization because you added it into Interceptor
setHeaders: { Authorization: JWT, },
Could you re-check your request header again.
Issue type
I'm submitting a
Issue description
Sorry for I'm new with node.js, angular, nebular I'm not sure is it my API that's wrong or my client side I tested Login API in postman and put the token in every other api header and it works
For client side I use Nebular Authentication and Interceptors I can log in, there's token generated and page redirect to the after login page but all data I try to get from other api wont show because the status code 401 Unauthorized, I also try the token generated to postman also unauthorized.
What I possibly doing wrong? And why its 401 Unauthorized but I can still login and access the page that i already guard with AuthGuard
Current behavior: login api works
but right after login, the api I need to access got unauthorized
Expected behavior: The token after login authorized so it can access all API, if unauthorized stay in login page
Related code: Here's app.module.ts
Here's interceptor
Here's app-routing.module.ts
Here's auth guard
Here's core.module.ts
Other information:
npm, node, OS, Browser
Angular, Nebular
Please help and sorry if I did any stupid mistake, Thank you!