Your Supabase auth call fails with:
AuthSessionMissingError: Auth session missing!
It usually appears on getUser(), updateUser() or signOut(), often right after a page load or on the server. Here is what it means and the safe fix.
What it means
These calls need a signed-in session to act on. The client looked for a session (an access token and refresh token) in its storage, found none, and refused. It is not a bad password or an expired token. There is simply no session where the client looked.
The 5 usual causes
- No one is signed in yet. The call runs before login, or after the user signed out.
- Server code cannot see the browser's session. In SSR frameworks the session lives in cookies. If your server client is not wired to read them, it sees nothing.
-
Different storage. The session was saved with one client instance and read by another, for example one created with
persistSession: false. -
A password reset or magic link page that loads before the session is set. The URL token needs a moment to be exchanged. Calling
updateUsertoo early fails. - Third-party cookies or storage blocked. Embedded apps and some privacy modes drop the stored session.
The fix, in order
- Check first with
supabase.auth.getSession(). If it returns null, handle the logged-out case instead of callinggetUser()blindly. - On the server, use the official SSR helper for your framework and pass it the request cookies.
- On reset or magic link pages, wait for the
onAuthStateChangeevent (PASSWORD_RECOVERYorSIGNED_IN) before callingupdateUser. - Use one shared client instance in the browser.
- Redirect to login when there is no session. Do not fall back to the
service_rolekey to make the call work.
The shortcut to avoid
Some quick fixes skip the user check and call the database with the service_role key from the server "so it just works". That key ignores row-level security. If a route does that without checking who is asking, any visitor can reach any data through it.
Check what your site exposes
The free read-only check at https://proofforge.live looks at your deployed site for leaked keys and open Supabase or Firebase data, and lists what it could not test. For user-to-user access, use the free two-account test: https://proofforge.live/two-account-test
Paid one-time fix reports are $9, $29 and $79, and the free scan does not require them.
Top comments (0)