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
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...
404 Resource not found on first page hit only
Was this page helpful?