Skip to content

Commit

Permalink
fix: added server_role
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickwebsdev committed Nov 8, 2024
1 parent 811bde1 commit 88735c4
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions src/lib/supabase/server_role.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,20 @@ import { Database } from '@/types/database';
export async function createServerRoleClient() {
const cookieStore = await cookies();

return createServerClient<Database>(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.SUPABASE_SERVICE_ROLE!,
{
cookies: {
getAll() {
return cookieStore.getAll();
},
setAll(cookiesToSet) {
try {
cookiesToSet.forEach(({ name, value, options }) => cookieStore.set(name, value, options));
} catch {
// The `setAll` method was called from a Server Component.
// This can be ignored if you have middleware refreshing
// user sessions.
}
},
return createServerClient<Database>(process.env.NEXT_PUBLIC_SUPABASE_URL!, process.env.SUPABASE_SERVICE_ROLE!, {
cookies: {
getAll() {
return cookieStore.getAll();
},
setAll(cookiesToSet) {
try {
cookiesToSet.forEach(({ name, value, options }) => cookieStore.set(name, value, options));
} catch {
// The `setAll` method was called from a Server Component.
// This can be ignored if you have middleware refreshing
// user sessions.
}
},
},
);
});
}

0 comments on commit 88735c4

Please sign in to comment.