chore: other code
This commit is contained in:
parent
1d4fbaf8e4
commit
a3d1cebd09
|
@ -1,18 +1,19 @@
|
||||||
import { createServerClient, type CookieOptions } from '@supabase/ssr'
|
import { createServerClient, type CookieOptions } from "@supabase/ssr";
|
||||||
import { cookies } from 'next/headers'
|
import { cookies } from "next/headers";
|
||||||
|
|
||||||
export const createClient = (cookieStore: ReturnType<typeof cookies>) => {
|
export const createClient = (cookieStore: ReturnType<typeof cookies>) => {
|
||||||
return createServerClient(
|
return createServerClient(
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
process.env.SUPABASE_SECRET_KEY ||
|
||||||
|
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
||||||
{
|
{
|
||||||
cookies: {
|
cookies: {
|
||||||
get(name: string) {
|
get(name: string) {
|
||||||
return cookieStore.get(name)?.value
|
return cookieStore.get(name)?.value;
|
||||||
},
|
},
|
||||||
set(name: string, value: string, options: CookieOptions) {
|
set(name: string, value: string, options: CookieOptions) {
|
||||||
try {
|
try {
|
||||||
cookieStore.set({ name, value, ...options })
|
cookieStore.set({ name, value, ...options });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// The `set` method was called from a Server Component.
|
// The `set` method was called from a Server Component.
|
||||||
// This can be ignored if you have middleware refreshing
|
// This can be ignored if you have middleware refreshing
|
||||||
|
@ -21,7 +22,7 @@ export const createClient = (cookieStore: ReturnType<typeof cookies>) => {
|
||||||
},
|
},
|
||||||
remove(name: string, options: CookieOptions) {
|
remove(name: string, options: CookieOptions) {
|
||||||
try {
|
try {
|
||||||
cookieStore.set({ name, value: '', ...options })
|
cookieStore.set({ name, value: "", ...options });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// The `delete` method was called from a Server Component.
|
// The `delete` method was called from a Server Component.
|
||||||
// This can be ignored if you have middleware refreshing
|
// This can be ignored if you have middleware refreshing
|
||||||
|
@ -30,5 +31,5 @@ export const createClient = (cookieStore: ReturnType<typeof cookies>) => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
);
|
||||||
}
|
};
|
||||||
|
|
10
utils/supabase/serversignout.ts
Normal file
10
utils/supabase/serversignout.ts
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
"use server";
|
||||||
|
|
||||||
|
import { cookies } from "next/headers";
|
||||||
|
import { createClient } from "@/utils/supabase/server";
|
||||||
|
|
||||||
|
export const signOut = async () => {
|
||||||
|
const cookieStore = cookies();
|
||||||
|
const supabase = createClient(cookieStore);
|
||||||
|
await supabase.auth.signOut();
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user