This commit is contained in:
hailin 2025-05-21 00:35:46 +08:00
parent 58a0278511
commit 87ae03b931
1 changed files with 17 additions and 13 deletions

View File

@ -1,22 +1,26 @@
import { Database, Tables } from "@/supabase/types"
import { VALID_ENV_KEYS } from "@/types/valid-keys"
import { createServerClient } from "@supabase/ssr"
//import { createServerClient } from "@supabase/ssr"
import { getSupabaseServerClient } from "@/lib/supabase/server"
import { cookies } from "next/headers"
import { getRuntimeEnv } from "@/lib/ipconfig" // 新增引入
export async function getServerProfile() {
const cookieStore = cookies()
const supabase = createServerClient<Database>(
getRuntimeEnv("SUPABASE_URL") ?? "http://localhost:8000",
process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
{
cookies: {
get(name: string) {
return cookieStore.get(name)?.value
}
}
}
)
// const cookieStore = cookies()
// const supabase = createServerClient<Database>(
// getRuntimeEnv("SUPABASE_URL") ?? "http://localhost:8000",
// process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY!,
// {
// cookies: {
// get(name: string) {
// return cookieStore.get(name)?.value
// }
// }
// }
// )
const supabase = getSupabaseServerClient()
const user = (await supabase.auth.getUser()).data.user
if (!user) {