Intermittent 404s with Convex Auth + NextJS
I'm using Convex Auth with NextJS but getting occasional Vercel 404s when navigating to "/" after not having used my app in a while. The 404 goes away when I refresh and doesn't happen when the app is "warm."
I thought it was a NextJS issue at first but this random StackOverflow poster ran into the same issue with Convex + NextJS, which is suspicious. It's making me believe it's something about how Convex Auth interacts with NextJS.
My setup is the same as this template: I have a ConvexAuthNextjsServerProvider with a ConvexAuthNextjsProvider inside. And then use
convexAuth.isAuthenticated()
+ nextjsMiddlewareRedirect
to send users to the right location based on whether they're signed in or not.
It looks like it only happens when the user is signed in, in which case I try to redirect them from /
to /dashboard
using nextjsMiddlewareRedirect.
The network tab shows the request for /
404ing, but it does have a Location response header with value /dashboard
I'm using Next 15.4.5
, Convex ^1.23.0
and Convex Auth ^0.0.81
. I've tried many solutions and random hacks so this is in many ways a hail mary to see if this sounds familiar to anyone!
Thanks so much!Stack Overflow
404 Resource not found on first page hit only
Next.js 15.3.1, Convex 1.23.0, @convex-dev/auth 0.0.82 PWA
This issue IS NOT related to or caused by Convex - this im sure of. However, I have googled and tried to fix this for six weeks now. I fig...
2 Replies
Thanks for posting in <#1088161997662724167>.
Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets.
- Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.)
- Use search.convex.dev to search Docs, Stack, and Discord all at once.
- Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI.
- Avoid tagging staff unless specifically instructed.
Thank you!
I have encountered this, it's hard to pin down. For some reason the request fails to match anything in the middleware, leading to a 404. I'll try to take a closer look soon, reducing jwt expiration to something very short may help to quickly reproduce.