Open
Description
Checklist
- The issue can be reproduced in the nextjs-auth0 sample app (or N/A).
- I have looked into the Readme, Examples, and FAQ and have not found a suitable solution or answer.
- I have looked into the API documentation and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
- I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- I agree to the terms within the Auth0 Code of Conduct.
Description
In v4.5.1 (latest version at the time of writing), a security patch was released to ensure JWTs are expired alongside the cookies.
However, that has caused some side-effects - the middleware now crashes with HTTP 500 whenever an expired JWT hits the server:
[JWTExpired: "exp" claim timestamp check failed]
I am not sure this is an intentional behaviour or an oversight? Coming from the user's perspective, I felt like the middleware should have caught this and handled as if there is no session, instead of throwing. How it is handled could dependant on the route - e.g. profile should return 401, and for non-auth routes probably short circuit the session updates.
Reproduction
- Obtain an expired JWT
- Hit the Next.js server wired up with the Auth0 middleware
- Boom, HTTP 500
Additional context
No response
nextjs-auth0 version
4.5.1
Next.js version
14.2.28
Node.js version
22.14.0