Mael Halna
Mael Halna
KKinde
Created by Mael Halna on 5/7/2025 in #💻┃support
Intermittent Next.js Auth Errors: "No response returned", "State not found", "Refresh failed"
Hey Kinde team! We're running into a few tricky, intermittent authentication errors with the @kinde-oss/kinde-auth-nextjs SDK (Version: 2.6.1 ) in our Next.js (App Router) app on Vercel. Using NextJs 13.5.9 Key issues observed (in production): NEW: /api/auth/login 500 Error Log: Error: No response is returned from route handler .../app/api/auth/[kindeAuth]/route.ts Our [kindeAuth]/route.ts uses export const GET = handleAuth(); as per docs. Intermittent /api/auth/kinde_callback 500 Error Log: callback Error: Authentication flow: Received: [STATE_ID] | Expected: State not found Happens rarely (~1-2% of callbacks). Cookies use SameSite=Lax. Occasional /api/auth/setup 500 Error Log: ...access or id token expired - attempting refresh ... refresh tokens failed - returning error We're also seeing this "refresh failed" issue on /api/auth/setup in another, simpler Next.js project (same SDK/NextJs versions), which is interesting. Quick Checks Done: Verified critical Kinde env vars in Vercel. Confirmed app/api/auth/[kindeAuth]/route.ts structure matches Kinde docs. Middleware matcher excludes /api/auth/*. KINDE_DEBUG_MODE=true was enabled when these logs were captured. Could you offer any insights or suggest next steps for debugging these, especially the "No response returned" from /api/auth/login? We're concerned handleAuth() might have some edge cases. Also, any thoughts on the refresh token behavior appearing across projects? Thanks for your help!
7 replies