chore: remove Supabase dependency completely

This commit is contained in:
maulanasdqn
2026-01-21 20:52:03 +07:00
parent 3f30fbe89c
commit ae1864c134
6 changed files with 5 additions and 174 deletions
-60
View File
@@ -1,60 +0,0 @@
import { createClient, SupabaseClient } from '@supabase/supabase-js';
const supabaseUrl = import.meta.env.VITE_SUPABASE_URL;
const supabaseAnonKey = import.meta.env.VITE_SUPABASE_ANON_KEY;
// Lazy initialization - only create client when credentials are available
let _supabase: SupabaseClient | null = null;
const getSupabaseClient = (): SupabaseClient => {
if (!supabaseUrl || !supabaseAnonKey) {
throw new Error('Missing Supabase environment variables. Please set VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY.');
}
if (!_supabase) {
_supabase = createClient(supabaseUrl, supabaseAnonKey, {
auth: {
autoRefreshToken: true,
persistSession: true,
detectSessionInUrl: true,
storage: typeof window !== 'undefined' ? window.localStorage : undefined,
},
global: {
headers: {
'X-Client-Info': 'supabase-js-web',
},
},
});
}
return _supabase;
};
// Export a proxy that lazily initializes the client
export const supabase = new Proxy({} as SupabaseClient, {
get(_, prop) {
return getSupabaseClient()[prop as keyof SupabaseClient];
},
});
// Helper to create authenticated client (kept for backward compatibility)
// NOTE: With proper session management, this should no longer be needed
// Once session is set via supabase.auth.setSession(), the base client will have auth context
export const getAuthenticatedClient = (accessToken: string) => {
if (!supabaseUrl || !supabaseAnonKey) {
throw new Error('Missing Supabase environment variables. Please set VITE_SUPABASE_URL and VITE_SUPABASE_ANON_KEY.');
}
return createClient(supabaseUrl, supabaseAnonKey, {
auth: {
autoRefreshToken: false,
persistSession: false,
detectSessionInUrl: false,
},
global: {
headers: {
Authorization: `Bearer ${accessToken}`,
},
},
});
};
-1
View File
@@ -1 +0,0 @@
export * from './client';