feat: Implement a new authentication system with dedicated login and registration pages, an authenticated route layout, and updated routing.
This commit is contained in:
@@ -1,24 +1,28 @@
|
||||
import { createServerClient } from "@supabase/ssr"
|
||||
import { createServerOnlyFn } from "@tanstack/react-start"
|
||||
import { getCookies, setCookie } from "@tanstack/react-start/server"
|
||||
|
||||
const supabase_url = createServerOnlyFn(
|
||||
() => process.env.VITE_SUPABASE_URL as string
|
||||
)
|
||||
const supabase_key = createServerOnlyFn(
|
||||
() => process.env.VITE_SUPABASE_KEY as string
|
||||
)
|
||||
|
||||
export function getSupabaseServerClient() {
|
||||
return createServerClient(
|
||||
process.env.VITE_SUPABASE_URL as string,
|
||||
process.env.VITE_SUPABASE_KEY as string,
|
||||
{
|
||||
cookies: {
|
||||
getAll() {
|
||||
return Object.entries(getCookies()).map(([name, value]) => ({
|
||||
name,
|
||||
value,
|
||||
}))
|
||||
},
|
||||
setAll(cookies) {
|
||||
cookies.forEach((cookie) => {
|
||||
setCookie(cookie.name, cookie.value)
|
||||
})
|
||||
},
|
||||
return createServerClient(supabase_url(), supabase_key(), {
|
||||
cookies: {
|
||||
getAll() {
|
||||
return Object.entries(getCookies()).map(([name, value]) => ({
|
||||
name,
|
||||
value
|
||||
}))
|
||||
},
|
||||
setAll(cookies) {
|
||||
cookies.forEach((cookie) => {
|
||||
setCookie(cookie.name, cookie.value)
|
||||
})
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user