2024-05-24 17:57:03 -04:00
|
|
|
import { createServerClient, type CookieOptions } from "@supabase/ssr";
|
|
|
|
import { cookies } from "next/headers";
|
|
|
|
|
|
|
|
export const createClient = () => {
|
|
|
|
const cookieStore = cookies();
|
|
|
|
|
|
|
|
return createServerClient(
|
|
|
|
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
2024-06-08 19:43:26 -04:00
|
|
|
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
2024-05-24 17:57:03 -04:00
|
|
|
{
|
|
|
|
cookies: {
|
|
|
|
get(name: string) {
|
|
|
|
return cookieStore.get(name)?.value;
|
|
|
|
},
|
|
|
|
set(name: string, value: string, options: CookieOptions) {
|
|
|
|
try {
|
|
|
|
cookieStore.set({ name, value, ...options });
|
|
|
|
} catch (error) {
|
|
|
|
// The `set` method was called from a Server Component.
|
|
|
|
// This can be ignored if you have middleware refreshing
|
|
|
|
// user sessions.
|
|
|
|
}
|
|
|
|
},
|
|
|
|
remove(name: string, options: CookieOptions) {
|
|
|
|
try {
|
|
|
|
cookieStore.set({ name, value: "", ...options });
|
|
|
|
} catch (error) {
|
|
|
|
// The `delete` method was called from a Server Component.
|
|
|
|
// This can be ignored if you have middleware refreshing
|
|
|
|
// user sessions.
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
2024-06-08 19:50:08 -04:00
|
|
|
};
|