Skip to content

Fix Safari sign-in: cookie-based auth storage - #10

Merged
wjleece merged 1 commit into
mainfrom
fix/safari-oauth-cookie-storage
Sep 20, 2026
Merged

wjleece merged 1 commit into
mainfrom
fix/safari-oauth-cookie-storage

Conversation

@wjleece

@wjleece wjleece commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Google sign-in completed on Safari but the page kept showing "Sign in" instead of "Sign out" (worked fine on Chrome). Bill confirmed reload didn't fix it (session never established) but disabling Safari's "Prevent Cross-Site Tracking" did — pointing at Safari's ITP evicting the PKCE code_verifier from localStorage during the redirect through the shared supabase.co domain.

Swaps @supabase/supabase-js's createClient for @supabase/ssr's createBrowserClient, which stores the verifier/session in a cookie instead — same auth.* API, no backend needed, no other code changes.

Test plan

  • pnpm test green (22/22)
  • pnpm astro check — no new type errors
  • Verified full sign-in round trip in Chrome: sign-in completes, session persists across reload, watchlist write persists across reload, clean sign-out
  • Needs Bill to verify in real Safari — I can't run Safari myself
  • CI green on this PR (gating the merge)

🤖 Generated with Claude Code

Bill hit this live: Google sign-in completed but the page still showed
"Sign in" on Safari (worked fine on Chrome). Reload didn't fix it --
confirmed the session was never actually established, not a rendering
race.

Root cause: Supabase's PKCE flow writes a one-time code_verifier to
localStorage right before redirecting to Google, then reads it back after
the redirect completes. Safari's Intelligent Tracking Prevention restricts
JS-writable storage around navigations that bounce through a domain it
can't vouch for -- and xkobcymztzpievdxchqc.supabase.co is exactly that:
a shared hostname used by thousands of unrelated Supabase projects, which
reads as a bounce-tracking pattern to Safari's classifier. The verifier
gets evicted mid-flow, the code exchange silently fails, no session gets
created. Confirmed directly: disabling "Prevent Cross-Site Tracking" in
Safari settings fixed it for Bill.

Fix: swap @supabase/supabase-js's createClient for @supabase/ssr's
createBrowserClient, which stores the verifier and session in a cookie
instead of localStorage. Cookies set during a top-level navigation aren't
subject to the same ITP restriction. No backend required -- this works in
a plain client-rendered page, same auth.* API, so no other code changed.

Verified end-to-end in Chrome (still can't run real Safari myself): full
sign-in round trip, session persists across reload, watchlist write
persists across reload, clean sign-out.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@wjleece
wjleece merged commit 10eee3b into main Sep 20, 2026
1 check passed
@wjleece
wjleece deleted the fix/safari-oauth-cookie-storage branch September 20, 2026 18:40
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.

1 participant