The knowledge sources don’t contain a report of exactly “works for one navigation, then every further navigation 307s,” but they do describe very similar “works in dev, breaks / logs out in prod” AuthKit + Next.js behaviors. I’ll stick to what’s documented and what’s been seen in those threads.
Given:
authkit(request, { debug: true }) returns session { user: null } on that second navigation
- AuthKit then issues a 307 to
.../user_management/authorize
- First login + first navigation to dashboard do work
this means: on that second navigation, AuthKit is not seeing a valid session cookie anymore, even though it did just moments before. That’s why it’s redirecting.
From the Convex + WorkOS docs and Discord thread, the production‑only “session disappears” issues have almost always boiled down to one of:
- Cookie not being sent on some requests
AuthKit’s session is stored in a cookie. If that cookie is:
- scoped to a different domain (e.g.
example.com vs www.example.com), or
- not sent on some routes because of path / domain / HTTPS differences,
then some navigations will see session.user and others will see null, causing exactly the “sometimes logged in, sometimes 307” behavior.
The Convex docs emphasize that WORKOS_COOKIE_PASSWORD and redirect URI must be consistent and correctly configured per environment, but they don’t go into cookie flags in detail. [Config dev/prod]
- Prod vs dev WorkOS app / redirect URI mismatch
Even if you’ve checked env vars, a subtle mismatch like:
NEXT_PUBLIC_WORKOS_REDIRECT_URI using <https://your-domain.com/callback> but the app is actually served at <https://www.your-domain.com,> or
- WorkOS Dashboard redirect URI not matching the exact origin you’re using in prod,