feat(confidence-engine): establish authenticated product boundary

This commit is contained in:
2026-09-08 16:30:07 +01:00
parent 1c17452bee
commit 30bf44f2e5
22 changed files with 487 additions and 8 deletions
+33
View File
@@ -0,0 +1,33 @@
import { createServerClient } from "@supabase/ssr";
import { cookies } from "next/headers";
function getSupabaseConfig() {
return {
url: process.env.NEXT_PUBLIC_SUPABASE_URL,
key: process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY,
};
}
export function createServerSupabaseClient() {
const cookieStore = cookies();
const { url, key } = getSupabaseConfig();
return createServerClient(url, key, {
cookies: {
getAll() {
return cookieStore.getAll();
},
setAll(cookiesToSet) {
try {
cookiesToSet.forEach(({ name, value, options }) => cookieStore.set(name, value, options));
} catch {
// Server Components cannot write cookies; middleware refreshes sessions.
}
},
},
});
}
export async function getAuthenticatedUser() {
const { data: { user } } = await createServerSupabaseClient().auth.getUser();
return user;
}