-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getAccessToken expiration recovery #1718
Comments
This seems like something I'm having issues with. I'm getting: Even though I'm using it in the /api/endpoint/route.ts as per docs: With withApiAuthRequired which passes but then getAccessToken gets invalid token after a while. I think it's the same case as in here: nextauthjs/next-auth#6642 (comment) even though, it's different library. |
anybody found a solution for this? why does not middleware automatically logs out user when token is expired? |
Checklist
Description
Let's say client navigates to new page. And in the server component for that page we try to get access token, if getAccessToken was expired in the mean time trying to get one will throw an error. Even if you wrap your middleware with authRequired getAccessToken throws because you still have a session(so you pass through authRequired) but your access token expired so it throws an error.
I couldn't find any examples what to do in this scenario going through docs. I've tried redirecting user to /api/auth/login, but that also doesn't work properly because nextjs tries to fetch it as rsc payload first and then falls back to browser navigation and finally recovers. Is there a recommended way for doing this?
Reproduction
Additional context
No response
nextjs-auth0 version
3.5.0
Next.js version
14.0.3
Node.js version
20.9.0
The text was updated successfully, but these errors were encountered: