- Refactored UserContext.tsx (67 lines simplified) - Simplified supabaseClient.ts (82 lines reduced) - Updated .env.development for local dev
38 lines
910 B
TypeScript
38 lines
910 B
TypeScript
import { createClient, SupabaseClient } from '@supabase/supabase-js';
|
|
import { logger } from './debugConfig';
|
|
|
|
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
|
|
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY;
|
|
|
|
if (!supabaseUrl || !supabaseAnonKey) {
|
|
throw new Error('Missing Supabase configuration');
|
|
}
|
|
|
|
logger.info('supabase-client', '🔄 Initializing Supabase client', {
|
|
url: supabaseUrl,
|
|
hasKey: !!supabaseAnonKey,
|
|
});
|
|
|
|
export const supabase: SupabaseClient = createClient(
|
|
supabaseUrl,
|
|
supabaseAnonKey,
|
|
{
|
|
auth: {
|
|
flowType: 'pkce',
|
|
autoRefreshToken: true,
|
|
persistSession: true,
|
|
detectSessionInUrl: false,
|
|
storage: window.localStorage,
|
|
storageKey: 'supabase.auth.token',
|
|
debug: true
|
|
},
|
|
global: {
|
|
headers: {
|
|
'X-Client-Info': 'classroom-copilot',
|
|
},
|
|
},
|
|
db: {
|
|
schema: 'public'
|
|
}
|
|
}
|
|
); |