Skip to content

fix: use cookieOptions.name over auth.storageKey in createServerClient - #303

Open
dasjideepak wants to merge 1 commit into
supabase:mainfrom
dasjideepak:fix/storage-key-precedence
Open

dasjideepak wants to merge 1 commit into
supabase:mainfrom
dasjideepak:fix/storage-key-precedence

Conversation

@dasjideepak

Copy link
Copy Markdown

Fixes #302

When both cookieOptions.name and auth.storageKey are set, createBrowserClient uses cookieOptions.name but createServerClient uses auth.storageKey. The server then reads a different cookie than the browser wrote and gets no session. This makes the server use the same precedence as the browser.

  • Moved the cookieOptions.name override after ...options?.auth in createServerClient
  • Added a test that reads the session from the cookieOptions.name cookie with auth.storageKey also set (fails before, passes after)
  • Note: this changes behaviour for anyone who sets both options on the server only. Happy to flip the direction (make the browser follow auth.storageKey) if you prefer.

createBrowserClient lets cookieOptions.name override auth.storageKey, but
createServerClient did the opposite. With both options set, the server read
a different cookie than the browser wrote and found no session.
@dasjideepak
dasjideepak requested review from a team as code owners September 26, 2026 18:34

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

createServerClient and createBrowserClient disagree on storage key when both cookieOptions.name and auth.storageKey are set

1 participant