From faba60a80db4eebecfc783d7412aa591664bddfd Mon Sep 17 00:00:00 2001 From: Max Metral Date: Wed, 18 Oct 2023 17:19:47 -0400 Subject: [PATCH] fix(env): use APP_ENV instead of NODE_ENV if present --- src/provider.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/provider.ts b/src/provider.ts index 51d99e6..183601d 100644 --- a/src/provider.ts +++ b/src/provider.ts @@ -3,7 +3,10 @@ import minimist from 'minimist'; import { environmentPatterns } from './common'; export function convenience() { - let nodeEnv = process.env.NODE_ENV || 'development'; + // NextJS philosophy is don't use non-standard NODE_ENV values, and this seems + // reasonable. APP_ENV includes staging, which is not a NODE_ENV value. + // So we will try to pick the best one we can find + let nodeEnv = process.env.APP_ENV || process.env.NODE_ENV || 'development'; const env: Record = {}; // Normalize env and set convenience values. @@ -27,7 +30,7 @@ export function environmentVariables(ignore: string[]) { // process.env is not a normal object, so we // need to map values. for (const env of Object.keys(process.env)) { - // env:env is decided by process.env.NODE_ENV. + // env:env is decided by process.env.APP_ENV or process.env.NODE_ENV. // Not allowing process.env.env to override the env:env value. if (ignore.indexOf(env) < 0) { result[env] = process.env[env];