This commit is contained in:
parent
1ddbf1c13a
commit
0aa86587c3
|
|
@ -3,13 +3,22 @@ import { getRuntimeEnv } from '@/lib/ipconfig' // 路径按你项目实际调整
|
||||||
|
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
let ip: string | null = null
|
let ip: string | null = null
|
||||||
|
let res: string | undefined = undefined
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await getRuntimeEnv('SUPABASE_URL')
|
res = await getRuntimeEnv('SUPABASE_URL')
|
||||||
ip = res ?? null
|
ip = res ?? null
|
||||||
} catch (e) {
|
|
||||||
|
console.log('[health-check] getRuntimeEnv("SUPABASE_URL") 返回:', res)
|
||||||
|
console.log('[health-check] ip 赋值结果:', ip)
|
||||||
|
} catch (e: any) {
|
||||||
ip = null
|
ip = null
|
||||||
|
console.error('[health-check] 捕获异常:', e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 额外打印进程环境变量(一次就行,便于调试)
|
||||||
|
console.log('[health-check] process.env.SUPABASE_URL =', process.env.SUPABASE_URL)
|
||||||
|
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
status: 'ok',
|
status: 'ok',
|
||||||
ip,
|
ip,
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ export async function getRuntimeEnv(key: string): Promise<string | undefined> {
|
||||||
// 服务端
|
// 服务端
|
||||||
const val = process.env[key];
|
const val = process.env[key];
|
||||||
const ip = extractIp(val);
|
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;
|
return ip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue