next.js
29e72273 - enhancement(with-supabase): replace getSession() with getUser() (#61564)

Commit
2 years ago
enhancement(with-supabase): replace getSession() with getUser() (#61564) ### What? Enhancement of _with-supabase example_. Replacing in **middelware.ts**, **supabase.auth.getSession()** with **supabase.auth.getUser()** ### Why? **Never trust supabase.auth.getSession() inside server code such as middleware**. It isn't guaranteed to revalidate the Auth token. **It's safe to trust getUser()** because it sends a request to the Supabase Auth server every time to revalidate the Auth token. [Setting up Server-Side Auth for Next.js](https://supabase.com/docs/guides/auth/server-side/nextjs)
Author
Parents
Loading