advance
This commit is contained in:
9
lib/supabase/server.ts
Normal file → Executable file
9
lib/supabase/server.ts
Normal file → Executable file
@@ -1,17 +1,16 @@
|
||||
import { cookies } from "next/headers";
|
||||
import { createServerClient, type CookieOptions } from "@supabase/ssr";
|
||||
import { readSupabasePublicConfig } from "@/lib/supabase/config";
|
||||
|
||||
export const supabaseServer = async () => {
|
||||
const url = process.env.NEXT_PUBLIC_SUPABASE_URL;
|
||||
const anonKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY;
|
||||
|
||||
if (!url || !anonKey) {
|
||||
const config = readSupabasePublicConfig();
|
||||
if (!config) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const cookieStore = await cookies();
|
||||
|
||||
return createServerClient(url, anonKey, {
|
||||
return createServerClient(config.url, config.anonKey, {
|
||||
cookies: {
|
||||
getAll() {
|
||||
return cookieStore.getAll();
|
||||
|
||||
Reference in New Issue
Block a user