This commit is contained in:
hailin 2025-06-16 14:06:26 +08:00
parent 1ddbf1c13a
commit 0aa86587c3
2 changed files with 12 additions and 3 deletions

View File

@ -3,13 +3,22 @@ import { getRuntimeEnv } from '@/lib/ipconfig' // 路径按你项目实际调整
export async function GET() {
let ip: string | null = null
let res: string | undefined = undefined
try {
const res = await getRuntimeEnv('SUPABASE_URL')
res = await getRuntimeEnv('SUPABASE_URL')
ip = res ?? null
} catch (e) {
console.log('[health-check] getRuntimeEnv("SUPABASE_URL") 返回:', res)
console.log('[health-check] ip 赋值结果:', ip)
} catch (e: any) {
ip = null
console.error('[health-check] 捕获异常:', e)
}
// 额外打印进程环境变量(一次就行,便于调试)
console.log('[health-check] process.env.SUPABASE_URL =', process.env.SUPABASE_URL)
return NextResponse.json({
status: 'ok',
ip,

View File

@ -46,7 +46,7 @@ export async function getRuntimeEnv(key: string): Promise<string | undefined> {
// 服务端
const val = process.env[key];
const ip = extractIp(val);
console.log(`[env][server] 直接读取 process.env[${key}]:`, val, "提取IP:", ip);
console.log(`................[env][server] 直接读取 process.env[${key}]:`, val, "提取IP:", ip);
return ip;
}
}