From 554ad2a352f71c6d27329767f985eaf30a5f1bbd Mon Sep 17 00:00:00 2001 From: Millian Lamiaux Date: Tue, 17 Mar 2026 11:23:04 +0100 Subject: [PATCH] fix: use createBrowserClient for proper cookie-based auth - Switch from @supabase/supabase-js to @supabase/ssr createBrowserClient - This stores session in cookies instead of localStorage - Allows middleware to access session server-side - Fixes the missing cookies issue,description:Commit cookie auth fix --- admin-web/lib/supabase.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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