Closed nikitin-dev closed 2 years ago
@nikitin-dev I've been unable to replicate this behavior locally.
useGqlToken('<jwt>')
useGqlToken(null)
to logout the useruseGqlToken('<newToken>')
Any additional details you may be able to provide, or perhaps a reproduction would be a great help in addressing this
@nikitin-dev This should be fixed as of v0.1.28
That solved my issue. @Diizzayy, thanks a lot! You're really awesome guy. Thanks for your productive work and quick replies!
@nikitin-dev Happy to help!
Hi there! I have a problem with reassigning request headers. I'll start by describing my situation. I am using Nuxt version 3.0.0-rс.9 and strapi for the backend. In cookies, I have a JWT token, which is written after user authorization. Strapi provides the ability to request user data by forwarding a header with a JWT token. I want to receive information about the user's authentication status on the server side and, depending on the response, render the necessary markup on the server as well.
Here is my script in app.vue
As you see, i'am trying to reassign header using "useGqlToken" each time. The problem is: When i authorize the user №1, i get JWT, reload page and it works. My user is authorized and markup was rendered on the server. But when i logout and authorize user №2, i also get ANOTHER JWT token, reload page and i get data of user №1.
This is strange behavior, because in fact request must be executed with a new one JWT token. I dived into source code and console logged some stuff:
Action 1:
As you can see, we get valid jwt token in the useGqlToken function and valid request header in the setGqlState function as well In this case, i get expected result i.e. data of user №1.
Action 2:
We also get valid jwt token in the useGqlToken function and valid request header in the setGqlState function as well But in this case i get data of user №1 AGAIN.
The first log, named "TOKEN" it is:
The second log, named INSTANCE it is result of "setGqlState" function execution:
It looks like it's not working for reassigning token in headers. Or am I just doing something wrong?
Thanks in advance, looking forward to your reply)