I follow the instructions provided on the docs folder of the nestjs-angular bundle to test the api using <api_url>/swagger. First I made a POST to /api/auth/login and got a token. I then set the authorization by the button located on the top right of the page using the format Bearer <token>.
All the attempts to access locked paths on the api returned me error 401 - Unauthorized with the body:
{
"statusCode": 401,
"error": "Unauthorized"
}
Analyzing the post, swagger was sending on the header of my requests with the key Authentication: Bearer <my-token>. I believe the correct is Authorization: Bearer <my-token>.
I changed .addBearerAuth('Authentication', 'header') to .addBearerAuth('Authorization', 'header') on the main.ts from the backend project and got it working.
I follow the instructions provided on the docs folder of the nestjs-angular bundle to test the api using
<api_url>/swagger
. First I made a POST to/api/auth/login
and got a token. I then set the authorization by the button located on the top right of the page using the formatBearer <token>
.All the attempts to access locked paths on the api returned me error 401 - Unauthorized with the body:
Analyzing the post, swagger was sending on the header of my requests with the key
Authentication: Bearer <my-token>
. I believe the correct isAuthorization: Bearer <my-token>
.I changed
.addBearerAuth('Authentication', 'header')
to.addBearerAuth('Authorization', 'header')
on themain.ts
from the backend project and got it working.