Skip to content

Commit

Permalink
fix(env): use APP_ENV instead of NODE_ENV if present
Browse files Browse the repository at this point in the history
  • Loading branch information
djMax committed Oct 18, 2023
1 parent 78a1bbd commit faba60a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string | boolean> = {};

// Normalize env and set convenience values.
Expand All @@ -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];
Expand Down

0 comments on commit faba60a

Please sign in to comment.