-
Notifications
You must be signed in to change notification settings - Fork 26
Multiple Supabase client instances with debug code logging sessions in production #60
Open
Description
Issue
The project has at least 3 separate Supabase client configurations with inconsistent usage:
src/lib/supabase.ts-createBrowserClient(shared, with debug code)src/lib/supabase-admin.ts-createClientwith service role keysrc/utils/supabase/server.ts-createServerClientsrc/utils/supabase/client.ts- Another browser clientsrc/utils/supabase/authActions.ts- Auth-specific client
Why this matters
-
Debug code left in production -
supabase.ts:16-19:supabase.auth.getSession().then(res => { console.log("📦 [supabase.ts] Initial session:", res); }).catch(err => { console.error("❌ [supabase.ts] Session fetch error:", err); });
This runs every time the module is imported - on every page load, logging session data to the console.
-
Potential for service role key leaks - If
supabase-admin.tsis ever imported on the client side (even accidentally), theSUPABASE_SERVICE_ROLE_KEYwould be exposed to the browser, giving full database admin access. -
Inconsistent session handling - Different parts of the app use different client instances, which may have different cookie/session states.
Fix
- Remove the debug
getSession()code fromsupabase.ts - Ensure
supabase-admin.tsis only imported in server-side code (useif (typeof window === 'undefined')guard or move to a server-only directory) - Consolidate to a single client factory pattern
Metadata
Metadata
Assignees
Type
Fields
Give feedbackNo fields configured for issues without a type.