auto-claude: subtask-1-1 - Create Supabase middleware client utility
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
import { createServerClient } from '@supabase/ssr';
|
||||||
|
import { NextRequest, NextResponse } from 'next/server';
|
||||||
|
|
||||||
|
export function createClient(request: NextRequest, response: NextResponse) {
|
||||||
|
return createServerClient(
|
||||||
|
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||||
|
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
||||||
|
{
|
||||||
|
cookies: {
|
||||||
|
getAll() {
|
||||||
|
return request.cookies.getAll();
|
||||||
|
},
|
||||||
|
setAll(cookiesToSet) {
|
||||||
|
try {
|
||||||
|
cookiesToSet.forEach(({ name, value, options }) => {
|
||||||
|
response.cookies.set(name, value, options);
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
// Handle middleware context
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user