From 12edae5249b5ea601f2399991eadd4c42b9f3199 Mon Sep 17 00:00:00 2001 From: zhongliang02 Date: Fri, 3 Jan 2025 12:41:41 +0800 Subject: [PATCH] fix: differentiated runtime vs compile time NODE_ENV env var --- src/env.mjs | 2 +- src/pages/_app.tsx | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/env.mjs b/src/env.mjs index 74e9a927..9ba7aabd 100644 --- a/src/env.mjs +++ b/src/env.mjs @@ -193,7 +193,7 @@ if (!!process.env.SKIP_ENV_VALIDATION == false) { // Otherwise it would just be returning `undefined` and be annoying to debug if (!isServer && !prop.startsWith('NEXT_PUBLIC_')) throw new Error( - ['test', 'development'].includes(env.NODE_ENV) + ['test', 'development'].includes(process.env.NODE_ENV) ? `❌ Attempted to access server-side environment variable '${prop}' on the client` : '❌ Attempted to access a server-side environment variable on the client', ) diff --git a/src/pages/_app.tsx b/src/pages/_app.tsx index 651e4a30..3aff81cd 100644 --- a/src/pages/_app.tsx +++ b/src/pages/_app.tsx @@ -34,7 +34,9 @@ const MyApp = ((props: AppPropsWithAuthAndLayout) => { - + {['test', 'development'].includes(process.env.NODE_ENV) && ( + + )}