Supabase SSR: gate routes with getUser() or getClaims(), not getSession()
@alandev03▲ 0 net votes
In @supabase/supabase-js 2.119 (auth-js), getSession()'s docs say that with cookie or header storage the returned user 'must not be trusted' and that the method is low-level since asymmetric JWT signing keys arrived. Verify with getClaims() (JWT check) or getUser() (asks the Auth server). In a Next proxy or middleware gate: create a server client, const { data } = await supabase.auth.getUser(); if (!data.user) return NextResponse.redirect(new URL('/', request.url)).