Skip to content

Commit

Permalink
Create server.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
nodoubtz authored Mar 6, 2025
1 parent 4f0404c commit 3b58b0e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions utils/supabase/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

import { createServerClient, type CookieOptions } from "@supabase/ssr";
import { cookies } from "next/headers";

export const createClient = (cookieStore: ReturnType<typeof cookies>) => {
return createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
{
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 3b58b0e

Please sign in to comment.