diff --git a/admin-web/lib/supabase.ts b/admin-web/lib/supabase.ts index c696ce7..a2701c7 100644 --- a/admin-web/lib/supabase.ts +++ b/admin-web/lib/supabase.ts @@ -1,4 +1,4 @@ -import { createClient } from '@supabase/supabase-js' +import { createBrowserClient } from '@supabase/ssr' // Support both EXPO_PUBLIC_ (mobile) and NEXT_PUBLIC_ (web) prefixes const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL @@ -14,12 +14,12 @@ if (typeof window !== 'undefined') { console.log('Using NEXT_PUBLIC:', !!process.env.NEXT_PUBLIC_SUPABASE_URL) } -export const supabase = createClient(supabaseUrl, supabaseKey, { - auth: { - autoRefreshToken: true, - persistSession: true, - }, -}) +// Use createBrowserClient for proper cookie handling in Next.js +// This stores the session in cookies so middleware can access it +export const supabase = createBrowserClient( + supabaseUrl, + supabaseKey +) export const isSupabaseConfigured = () => { const url = process.env.NEXT_PUBLIC_SUPABASE_URL @@ -139,4 +139,4 @@ export interface Database { } } } -} +} \ No newline at end of file