- Symptom
- Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecureWarning appears even though your code never calls getSessionShows on every request in Next.js middleware or server components using @supabase/ssr
- Cause
- On the server, the session comes from cookies the client can forge, so the library wraps session.user in a proxy that warns on first access. Library internals and your own route guards that read session.user trigger it.
- Fix
- Use getClaims() to verify the JWT, or getUser() to ask the Auth server, whenever an identity decision is made on the server. Read only the access token from getSession, never the user object.
- Apply
const { data, error } = await supabase.auth.getClaims(); if (error || !data) return redirect('/login'); const userId = data.claims.sub;- Affected
- Server-side clients from @supabase/auth-js (gotrue-js) 2.63.0, released 2024-03-26, onward, as bundled in @supabase/supabase-js and used by @supabase/ssr
- Sources
Last verified 2026-10-15 · Confirmed by 0 builders