Closed Epenance closed 4 years ago
I also having the same problem. I guess i also one of the victims. What is the correct way to do it? Do you mind to show to me how to do it?
I also having the same problem. I guess i also one of the victims. What is the correct way to do it? Do you mind to show to me how to do it?
Ah... i got the answer already... use dedicated @ApiBearerAuth() instead of @ApiHeader... thanks for pointing out me to read at the bottom of document
how you can fix it ???
how you can fix it ??? please answer..
I'm submitting a...
Current behavior
In the Swagger docs the following is written:
When testing in Swagger the ApiHeader shows up, but will never be sent, when trying to test the resquest. My guess is that Authorization is reserved cause it actually works with
Additionally the Authorization headers are set with the
That is documented further down in the documentation, and once provided it will actually attach those headers to the request.
Expected behavior
Expected the Authorization header to be set when applied as shown in the documentation. It however only works if you use it with ApiSecurity decorater rather than the ApiHeader decorater.
Minimal reproduction of the problem with instructions
git clone git@gitlab.com:doshdk/nestjs-swagger-auth-example.git cd nestjs-swagger-auth-example docker-compose up -d yarn start:dev
Open browser and visit localhost:3000/docs Create a user, and login with your credentials to get a token.
Try the User profile and provide the bearer token. See that its not attached to the call.
What is the motivation / use case for changing the behavior?
Wrong documentation can lead to confusion, I myself was a victim of this 😄