Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
fix: baseSchema env validation not working
Browse files Browse the repository at this point in the history
  • Loading branch information
horvatz committed Nov 22, 2023
1 parent 2923086 commit b47c858
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/env.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,24 @@ const currentEnv = process.env.NODE_ENV || 'development'; // Default to 'develop
let envSchema;
switch (currentEnv) {
case 'development':
envSchema = { ...baseSchema, ...devSchema };
envSchema = {
server: { ...baseSchema.server, ...devSchema.server },
client: { ...baseSchema.client, ...devSchema.client },
};
break;
case 'test':
case 'staging':
envSchema = { ...baseSchema, ...stagingSchema };
envSchema = {
server: { ...baseSchema.server, ...stagingSchema.server },
client: { ...baseSchema.client, ...stagingSchema.client },
};
break;
case 'production':
envSchema = { ...baseSchema, ...productionSchema };
envSchema = {
server: { ...baseSchema.server, ...productionSchema.server },
client: { ...baseSchema.client, ...productionSchema.client },
};
break;
default:
throw new Error(`Unknown environment: ${currentEnv}`);
}

// Runtime environment variables (for Next.js edge runtimes or client-side)
Expand All @@ -76,7 +83,10 @@ const runtimeEnv = {
};

// Skip env validation flag (useful for Docker builds)
const skipValidation = !!process.env.SKIP_ENV_VALIDATION;
// Also skip on lint, see: https://github.com/t3-oss/t3-env/issues/102
const skipValidation =
!!process.env.SKIP_ENV_VALIDATION ||
process.env.npm_lifecycle_script === 'next lint';

// Treat empty strings as undefined
const emptyStringAsUndefined = true;
Expand Down

0 comments on commit b47c858

Please sign in to comment.