Replies: 4 comments 1 reply
-
Hi, were you able to solve this problem? I am working on a project with similar auth logic and I am stuck on how to correctly implement this... |
Beta Was this translation helpful? Give feedback.
-
What does it matter if the cookie is still there or not? Realistically you can just have a blacklist and/or whitelist on your backend to determine whether a cookie is still considered valid (in addition to verifying it), and on sign-out you should blacklist the token. Your backend authentication should then also check whether the cookie is blacklisted, and if it is, return a 401. That way even if the cookie is still available in NextJs, it won’t be considered valid. |
Beta Was this translation helpful? Give feedback.
-
I guess I'm out of luck too. I'm thinking of building the backend using Nest.js or Laravel but I could not wrap around my head on JWT. My API routes are protected using JWT. Which will be accessible on native mobile app too. I also have a login or registration page that gives JWT. And if I try to create my own adapter and just talk via rest, how can next.js routes talk to the protected routes of nest.js? I was thinking just save the token given by nestjs to session. But that will defeat the purpose of nest's refresh token. Might as well, drop this package and implement my own. :( |
Beta Was this translation helpful? Give feedback.
-
Facing similar issue |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Question 💬
I'm trying to figure out how the flow works when the API (written in NestJs) provides Authentication cookies.
Here are the authentication endpoints:
/signin sets the Access- (Max-Age: 240) and Refresh token cookie (Max-Age: 60000)
/refresh sets a new Access token Cookie
The UseGuards use the Passport
'jwt'
and'jwt-refresh-token'
guards[...nextauth]
file:Data retrieval
Now most data is retrieved within the getServerSideProps and some of the search data is done on the frontend.
On the getServerSideProps I get it by using:
The getData is an extension on:
So as you can see I pass through the cookies as default
Issue
Signing in seems to work great, navigating between pages also, until my token expires.
After some fiddling I seem to have 2 problems or maybe misunderstandings about the topic:
async jwt()
callback. How should take this on?How to reproduce ☕️
Refresh or navigate page after token expiry
Contributing 🙌🏽
No, I am afraid I cannot help regarding this
Beta Was this translation helpful? Give feedback.
All reactions