Skip to content

fix(build): honour .env.prod during the production build (#1919) - #2301

Open
alfonsodg wants to merge 1 commit into
OpenSignLabs:stagingfrom
alfonsodg:pr/1919-env-build
Open

alfonsodg wants to merge 1 commit into
OpenSignLabs:stagingfrom
alfonsodg:pr/1919-env-build

Conversation

@alfonsodg

Copy link
Copy Markdown

Problem

The deployment ships .env.prod, but Vite loads .env.production during a
production build, so the values in .env.prod were not applied at build time.
Only REACT_APP_SERVERURL was propagated at runtime, through the generated
env.js.

Affected files

  • apps/OpenSign/vite.config.js

Fix

The Vite config now also reads .env.prod when it is present, so the values
that the deployment actually ships are the ones that are compiled in.

Acceptance criteria

  • The values in .env.prod are applied during the build
  • The existing .env/.env.local behaviour is unchanged

Fixes OpenSignLabs#1919

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
Copilot AI balanced review requested due to automatic review settings October 21, 2026 22:31
@vercel

vercel Bot commented Oct 21, 2026

Copy link
Copy Markdown

@alfonsodg is attempting to deploy a commit to the prafull 's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Environment parsing, precedence, mode scoping, and Docker configuration delivery remain unresolved.

4 open issues
What changed in this PR

This PR attempts to make the frontend’s Vite build consume deployment settings from .env.prod, alongside the existing environment loading.

Changes:

  • Reads .env.prod from the build’s working directory when present.
  • Adds parsed values only when the existing environment lacks the key.
File Description
apps/​OpenSign/​vite.config.js Adds supplemental .env.prod loading to the frontend configuration.

Review effort: Balanced

// Load ALL env vars (no prefix filter). Also load .env.prod (deploy artifact) if present.
const env = loadEnv(mode, process.cwd(), "");
try {
const prodPath = path.resolve(process.cwd(), ".env.prod");
const env = loadEnv(mode, process.cwd(), "");
try {
const prodPath = path.resolve(process.cwd(), ".env.prod");
if (fs.existsSync(prodPath)) {
if (idx < 0) continue;
const key = trimmed.slice(0, idx).trim();
const value = trimmed.slice(idx + 1).trim();
if (key && !(key in env)) env[key] = value;
Comment on lines +15 to +24
const content = fs.readFileSync(prodPath, "utf8");
for (const line of content.split(/\r?\n/)) {
const trimmed = line.trim();
if (!trimmed || trimmed.startsWith("#")) continue;
const idx = trimmed.indexOf("=");
if (idx < 0) continue;
const key = trimmed.slice(0, idx).trim();
const value = trimmed.slice(idx + 1).trim();
if (key && !(key in env)) env[key] = value;
}

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants