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 - createClient with service role key
src/utils/supabase/server.ts - createServerClient
src/utils/supabase/client.ts - Another browser client
src/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.ts is ever imported on the client side (even accidentally), the SUPABASE_SERVICE_ROLE_KEY would 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 from supabase.ts
- Ensure
supabase-admin.ts is only imported in server-side code (use if (typeof window === 'undefined') guard or move to a server-only directory)
- Consolidate to a single client factory pattern
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 clientWhy this matters
Debug code left in production -
supabase.ts:16-19: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
getSession()code fromsupabase.tssupabase-admin.tsis only imported in server-side code (useif (typeof window === 'undefined')guard or move to a server-only directory)