[feat] setup supabase + notice and cfgx fetching

This commit is contained in:
Purp1e
2025-03-15 04:18:57 +08:00
parent 815cdb55f1
commit 3c5a354db1
14 changed files with 280 additions and 10 deletions

View File

@@ -0,0 +1,29 @@
import { createServerClient } from "@supabase/ssr"
import type { 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() {
// @ts-ignore
return cookieStore.getAll()
},
setAll(cookiesToSet) {
try {
cookiesToSet.forEach(({ name, value, options }) =>
// @ts-ignore
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.
}
},
},
},
)
}