mirror of
https://github.com/tiennm99/bsk.git
synced 2026-08-23 10:25:22 +00:00
- one strict checkJs jsconfig.json replaces tsconfig.json (keeps noUncheckedIndexedAccess); typecheck script now tsc -p jsconfig.json - next.config.ts -> next.config.mjs; vitest/playwright configs -> .js - db scripts run under plain node as .mjs; tsx devDep removed - generated Supabase types move to types/supabase-bsk.d.ts and db:gen-types redirects there - eslint drops eslint-config-next/typescript, adds eslint-plugin-jsdoc; factory-boundary no-restricted-imports globs now target .js
35 lines
1010 B
JavaScript
35 lines
1010 B
JavaScript
import "server-only";
|
|
import { createServerClient } from "@supabase/ssr";
|
|
import { cookies } from "next/headers";
|
|
import { serverEnv, SUPABASE_SCHEMA } from "@/lib/env/server";
|
|
|
|
/**
|
|
* Per-request Supabase client for RSC and Server Actions.
|
|
* MUST be called outside a `'use cache'` scope — it depends on cookies().
|
|
*/
|
|
export async function createSupabaseServerClient() {
|
|
const cookieStore = await cookies();
|
|
|
|
return createServerClient(
|
|
serverEnv.NEXT_PUBLIC_SUPABASE_URL,
|
|
serverEnv.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY,
|
|
{
|
|
db: { schema: SUPABASE_SCHEMA },
|
|
cookies: {
|
|
getAll() {
|
|
return cookieStore.getAll();
|
|
},
|
|
setAll(cookiesToSet) {
|
|
try {
|
|
for (const { name, value, options } of cookiesToSet) {
|
|
cookieStore.set({ name, value, ...options });
|
|
}
|
|
} catch {
|
|
// setAll throws from Server Components; the proxy-layer refresh handles it.
|
|
}
|
|
},
|
|
},
|
|
},
|
|
);
|
|
}
|