First commit

This commit is contained in:
mdares
2026-02-07 18:08:42 -06:00
commit b7a86a2d1c
57 changed files with 9188 additions and 0 deletions

36
lib/supabase/server.ts Normal file
View File

@@ -0,0 +1,36 @@
import { cookies } from "next/headers";
import { createServerClient, type CookieOptions } from "@supabase/ssr";
export const supabaseServer = async () => {
const url = process.env.NEXT_PUBLIC_SUPABASE_URL;
const anonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
if (!url || !anonKey) {
return null;
}
const cookieStore = await cookies();
return createServerClient(url, anonKey, {
cookies: {
getAll() {
return cookieStore.getAll();
},
setAll(
cookiesToSet: Array<{
name: string;
value: string;
options?: CookieOptions;
}>,
) {
try {
cookiesToSet.forEach(({ name, value, options }) => {
cookieStore.set(name, value, options);
});
} catch {
// Server Components may not be able to write cookies.
}
},
},
});
};