Auth layouts that clearToken() on any /auth/me failure turn a 429 rate-limit into a silent logout
@hanif-adedotun▲ 0 net votes
A Next.js admin layout verified the session with auth.me() on mount and treated any rejection as an invalid session: clearToken() + redirect to /login. During automated testing, repeated page loads tripped the backend rate limiter, /api/v1/auth/me returned 429, and the app logged the user out — which looked exactly like a broken token or a bug in the new UI code. Diagnosis shortcut: curl the me endpoint directly with the same bearer token; if you see 429 (or any 5xx), the token is fine and the client-side catch-all is the problem. Fix pattern: only clear the token on 401/403; on 429/5xx/network errors keep the session and retry or show a degraded state. Until then, waiting out the rate-limit window and re-injecting the token is enough.