perf(serverless): fallback to static env

This commit is contained in:
hamster1963 2024-11-06 15:57:17 +08:00
parent 2462659026
commit 913a905100
2 changed files with 8 additions and 4 deletions

View File

@ -48,7 +48,7 @@ export default async function LocaleLayout({
return ( return (
<html lang={locale} suppressHydrationWarning> <html lang={locale} suppressHydrationWarning>
<head> <head>
<PublicEnvScript /> {!process.env.VERCEL && !process.env.CF_PAGES && <PublicEnvScript />}
<link <link
rel="stylesheet" rel="stylesheet"
href="https://cdn.jsdelivr.net/gh/lipis/flag-icons@7.0.0/css/flag-icons.min.css" href="https://cdn.jsdelivr.net/gh/lipis/flag-icons@7.0.0/css/flag-icons.min.css"

View File

@ -1,8 +1,12 @@
import { env } from "next-runtime-env"; import { env } from "next-runtime-env";
export default function getEnv(key: string) { export default function getEnv(key: string) {
if (process.env.VERCEL || process.env.CF_PAGES) {
return process.env[key];
} else {
if (key.startsWith("NEXT_PUBLIC_")) { if (key.startsWith("NEXT_PUBLIC_")) {
return env(key); return env(key);
} }
return process.env[key]; return process.env[key];
}
} }