From 47f73eb0e4e37b08b7cd79b13a1729ca02ddbc81 Mon Sep 17 00:00:00 2001 From: Ryan Freeman <hello@ryanfreeman.dev> Date: Sun, 23 Feb 2025 21:10:38 +0000 Subject: [PATCH] Fix build --- .gitignore | 1 + lib/supabase/client.ts | 8 ++++++++ lib/supabase/server.ts | 29 +++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 lib/supabase/client.ts create mode 100644 lib/supabase/server.ts diff --git a/.gitignore b/.gitignore index 05bc2a5..c049d89 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ prisma/**/* .env supabase/ +!/lib/supabase .idea/ diff --git a/lib/supabase/client.ts b/lib/supabase/client.ts new file mode 100644 index 0000000..d5a732a --- /dev/null +++ b/lib/supabase/client.ts @@ -0,0 +1,8 @@ +import {createBrowserClient} from '@supabase/ssr' + +export function createClient() { + return createBrowserClient( + process.env.NEXT_PUBLIC_SUPABASE_URL!, + process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY! + ) +} \ No newline at end of file diff --git a/lib/supabase/server.ts b/lib/supabase/server.ts new file mode 100644 index 0000000..a46cfa6 --- /dev/null +++ b/lib/supabase/server.ts @@ -0,0 +1,29 @@ +import { createServerClient } from '@supabase/ssr' +import { cookies } from 'next/headers' + +export async function createClient() { + const cookieStore = await 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. + } + }, + }, + } + ) +} \ No newline at end of file