feat: hackathon

This commit is contained in:
Maulana Sodiqin
2025-11-25 01:47:56 +07:00
parent 5a99f216cb
commit 9e9bfc2793
53 changed files with 6892 additions and 927 deletions
+41
View File
@@ -0,0 +1,41 @@
import { createClient } from '@supabase/supabase-js';
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 environment variables');
}
// Create Supabase client with proper session management enabled
export const supabase = createClient(supabaseUrl, supabaseAnonKey, {
auth: {
autoRefreshToken: true, // ✅ Auto-refresh expired tokens
persistSession: true, // ✅ Persist session in storage
detectSessionInUrl: true, // ✅ Auto-detect OAuth callback
storage: typeof window !== 'undefined' ? window.localStorage : undefined,
},
global: {
headers: {
'X-Client-Info': 'supabase-js-web',
},
},
});
// 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) => {
return createClient(supabaseUrl, supabaseAnonKey, {
auth: {
autoRefreshToken: false,
persistSession: false,
detectSessionInUrl: false,
},
global: {
headers: {
Authorization: `Bearer ${accessToken}`,
},
},
});
};
+1
View File
@@ -0,0 +1 @@
export * from './client';