parent
3fb493f400
commit
1ce55e4091
2016 changed files with 23595 additions and 15662 deletions
35
lib/supabase/server.ts
Normal file
35
lib/supabase/server.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import { createServerClient } from '@supabase/ssr'
|
||||
import type { CookieOptions } from '@supabase/ssr'
|
||||
import { cookies } from 'next/headers'
|
||||
import { Database } from '../database.types'
|
||||
|
||||
export function createClient() {
|
||||
return createServerClient<Database>(
|
||||
process.env.NEXT_PUBLIC_SUPABASE_URL!,
|
||||
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
|
||||
{
|
||||
cookies: {
|
||||
get(name: string) {
|
||||
return cookies().get(name)?.value
|
||||
},
|
||||
set(name: string, value: string, options: CookieOptions) {
|
||||
cookies().set({
|
||||
name,
|
||||
value,
|
||||
...options,
|
||||
path: options?.path ?? '/',
|
||||
} as any) // Using any temporarily to bypass type checking
|
||||
},
|
||||
remove(name: string, options: CookieOptions) {
|
||||
cookies().set({
|
||||
name,
|
||||
value: '',
|
||||
...options,
|
||||
path: options?.path ?? '/',
|
||||
maxAge: 0,
|
||||
} as any) // Using any temporarily to bypass type checking
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue