diff --git a/frontend/app/layout.tsx b/frontend/app/layout.tsx index c5b2e601..e446008a 100644 --- a/frontend/app/layout.tsx +++ b/frontend/app/layout.tsx @@ -89,7 +89,7 @@ export default function RootLayout({ className={`${geistSans.variable} ${geistMono.variable} bg-gray-50 text-gray-900 antialiased transition-colors duration-300 dark:bg-neutral-950 dark:text-gray-100`} > {children} - {process.env.NODE_ENV === 'production' && } + {process.env.VERCEL === '1' && } ); diff --git a/frontend/lib/env/server-env.ts b/frontend/lib/env/server-env.ts index a1466f16..5923e043 100644 --- a/frontend/lib/env/server-env.ts +++ b/frontend/lib/env/server-env.ts @@ -4,14 +4,30 @@ type NetlifyEnv = { get?: (key: string) => string | undefined; }; +type NetlifyRuntime = { + env?: NetlifyEnv; +}; + +declare const Netlify: NetlifyRuntime | undefined; + +function getNetlifyRuntime(): NetlifyRuntime | undefined { + const fromGlobalThis = (globalThis as { Netlify?: NetlifyRuntime }).Netlify; + if (fromGlobalThis) return fromGlobalThis; + + if (typeof Netlify !== 'undefined') return Netlify; + + return undefined; +} + function readFromNetlifyEnv(key: string): string | undefined { - const maybeNetlify = (globalThis as { Netlify?: { env?: NetlifyEnv } }).Netlify; - const value = maybeNetlify?.env?.get?.(key); + const runtime = getNetlifyRuntime(); + const value = runtime?.env?.get?.(key); return typeof value === 'string' && value.trim() ? value.trim() : undefined; } export function readServerEnv(key: string): string | undefined { const fromProcess = process.env[key]?.trim(); if (fromProcess) return fromProcess; + return readFromNetlifyEnv(key); }