Repository navigation
Fix Safari sign-in: cookie-based auth storage - #10
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_verifierfromlocalStorageduring the redirect through the sharedsupabase.codomain.Swaps
@supabase/supabase-js'screateClientfor@supabase/ssr'screateBrowserClient, which stores the verifier/session in a cookie instead — sameauth.*API, no backend needed, no other code changes.Test plan
pnpm testgreen (22/22)pnpm astro check— no new type errors🤖 Generated with Claude Code