Error 401 on Angular-NestJs page when refreshing token


I have created an application with Angular as Frontend and NestJs as Backend.

In Angular I have put the authentication button and it works correctly. When the user authenticates, the request to /token is made correctly and this value is used to add it to the headers that will make the requests to the NestJS API. It works correctly, however, when a new request is made to /token (for example when refreshing the page), when sending the token through the headers, I receive a 401 error from NestJS.

I have to say that NestJS uses Passport JWT as authentication strategy.

I have not been able to determine why it does not work on subsequent requests (but it does on the first one). Am I missing something?

I fixed the issue by adding the issuer parameter in the Angular interceptor configuration that adds the token in the API request headers. That way the API can now correctly validate the refreshed tokens.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.