Time Remaining4:00
mediumDependenciesNext.js

The env mismatch

A developer asked an AI assistant to read a feature-flag environment variable to conditionally enable a new checkout flow. The suggested code works perfectly for the whole team locally, but the feature silently never turns on once deployed.

featureFlags.ts
export function isNewCheckoutEnabled(): boolean {
  return process.env.ENABLE_NEW_CHECKOUT === 'true';
}

The team's .env.local file has ENABLE_NEW_CHECKOUT=true and it works for everyone locally. Why is the feature silently disabled in production?

.env.local is gitignored and never deployed — if the variable was never added to production's environment, process.env.ENABLE_NEW_CHECKOUT is undefined, and undefined === 'true' is false.
process.env values are always strings in development but booleans in production, so the comparison type-mismatches.
Environment variables can only be read inside API routes, never in regular application code.
ENABLE_NEW_CHECKOUT needs a NEXT_PUBLIC_ prefix to be readable anywhere in a Next.js app.