You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Multiple unconditional console.log statements were added for Sentry enablement diagnostics; consider gating them behind a debug flag or removing to reduce noise in production.
The merging step concatenates .env.default then .env.production; verify that duplicate keys from .env.default do not override downstream due to tooling quirks and that Next.js loads .env.production after merge as intended.
RUN if [ -f .env.production ]; then \
# In CI/CD: merge defaults with production (production takes precedence)
cat .env.default .env.production > .env.merged && mv .env.merged .env.production; \
elif [ -f .env ]; then \
# Local with custom .env: merge defaults with .env
cat .env.default .env > .env.merged && mv .env.merged .env; \
else \
# Local without custom .env: use defaults
cp .env.default .env; \
fi
getAppEnv now falls back to APP_ENV; confirm APP_ENV is not set in local shells/CI unintentionally, which could override NEXT_PUBLIC_APP_ENV and lead to unexpected behavior.
exportfunctiongetAppEnv(): AppEnv{constenv=process.env.NEXT_PUBLIC_APP_ENV||process.env.APP_ENV;if(env==="dev")returnAppEnv.DEV;if(env==="prod")returnAppEnv.PROD;// Some places use prod and others productionif(env==="production")returnAppEnv.PROD;
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sentry was not being enabled in dev/prod deployments because environment variables were being incorrectly overwritten during the Docker build process.
Changes 🏗️
.env.default
from overwriting.env.production
valuesNODE_ENV=production
to build stage to ensure Next.js looks for production env files.env.production
doesn't exist).env.production
exists (CI/CD), now merges defaults with production values properlyChecklist 📋
For code changes:
docker compose up
NEXT_PUBLIC_APP_ENV=dev
in built JavaScriptNEXT_PUBLIC_APP_ENV=prod
in built JavaScriptisProdOrDev=true
)For configuration changes:
.env.default
is updated or already compatible with my changesdocker-compose.yml
is updated or already compatible with my changesTechnical Details
Root Cause:
.env.production
with correct values (e.g.,NEXT_PUBLIC_APP_ENV=dev
).env
from.env.default
.env.production
first, then.env
second.env
is loaded after.env.production
, it overwrites the values.env.default
hasNEXT_PUBLIC_APP_ENV=local
, causinggetAppEnv()
to return "local" instead of "dev"/"prod"isProdOrDev
evaluate tofalse
, disabling SentrySolution:
The Dockerfile now checks if
.env.production
exists:.env.default
+.env.production
→.env.production
(production values take precedence).env.default
+.env
→.env
(user values take precedence)This ensures production deployments get the correct environment variables while preserving local development workflow.
🤖 Description generated + Investigation assisted with Claude Code
Co-Authored-By: Claude [email protected]