mirror of
https://github.com/arsvendg/Stirling-PDF.git
synced 2026-07-14 10:34:06 +02:00
The console warned "Multiple GoTrueClient instances detected in the same browser context" and storage endpoints (/api/v1/storage/folders, /files) kept 401ing even after a successful token refresh. Cause: the SaaS bundle instantiated TWO Supabase clients on the same sb-<ref>-auth-token storage key. :saas/auth/supabase.ts creates the primary client (used by UseSession + apiClient), while billing / licensing / user-management code imports @app/services/supabaseClient, which fell through to :proprietary/services/supabaseClient.ts and called createClient() again. Each client runs its own autoRefreshToken timer, so they rotate the refresh token out from under each other → "Already Used" refresh failures and spurious 401s, plus a residual /login flash. Add a :saas override of @app/services/supabaseClient that re-exports the single instance from @app/auth/supabase. The path mapping (@app/* → src/saas/* → src/proprietary/* → src/core/*) now resolves every consumer to the same client, so the :proprietary createClient() is never bundled in the SaaS build. Co-Authored-By: Claude Opus 4.8 <[email protected]>