Multiple Supabase client instances with debug code logging sessions in production

Aperta
#60 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
next.js, supabase, typescript

Direzione di ricerca

Start by reading src/lib/supabase.ts, src/lib/supabase-admin.ts, src/utils/supabase/server.ts, src/utils/supabase/client.ts, and src/utils/supabase/authActions.ts. Trace which modules import each client and how browser, server, and service-role usage are separated. Done means the debug session logging is gone, the service-role client cannot reach browser code, and the remaining client usage follows one consistent pattern.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug help wanted

Issue

The project has at least 3 separate Supabase client configurations with inconsistent usage:

  1. src/lib/supabase.ts - createBrowserClient (shared, with debug code)
  2. src/lib/supabase-admin.ts - createClient with service role key
  3. src/utils/supabase/server.ts - createServerClient
  4. src/utils/supabase/client.ts - Another browser client
  5. src/utils/supabase/authActions.ts - Auth-specific client

Why this matters

  1. 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.

  2. 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.

  3. Inconsistent session handling - Different parts of the app use different client instances, which may have different cookie/session states.

Fix

  1. Remove the debug getSession() code from supabase.ts
  2. Ensure supabase-admin.ts is only imported in server-side code (use if (typeof window === 'undefined') guard or move to a server-only directory)
  3. Consolidate to a single client factory pattern
Lingua principale
TypeScript
Stelle
0
Fork
26
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di OpenLake/RateMyCourse

Tutte le issue di OpenLake/RateMyCourse

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.