Skip to content

Commit 196f63e

Browse files
committed
fix: skip dotenv in production, secrets come from Kubernetes
1 parent 16ff57d commit 196f63e

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

apps/backend/src/env.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ const envPath = path.resolve(__dirname, '../../../.env');
88
const result = dotenv.config({ path: envPath });
99

1010
if (result.error) {
11-
// Keep failing fast but avoid leaking via console in production code paths.
12-
// This file runs before the Fastify logger is available; throw so the process exits.
13-
throw result.error;
14-
} else {
15-
// .env loaded successfully
11+
if (process.env.NODE_ENV === 'production') {
12+
// In production, env vars come from Kubernetes secrets — .env file is not expected.
13+
} else {
14+
// In development, .env is required. Fail fast.
15+
throw result.error;
16+
}
1617
}

0 commit comments

Comments
 (0)