Skip to content

#1128 - Read FORCE_CONFIG_PATH at runtime in production builds - #1161

Open
EmbryoSpace wants to merge 1 commit into
NASA-AMMOS:developmentfrom
EmbryoSpace:fix-force-config-path-runtime
Open

EmbryoSpace wants to merge 1 commit into
NASA-AMMOS:developmentfrom
EmbryoSpace:fix-force-config-path-runtime

Conversation

@EmbryoSpace

@EmbryoSpace EmbryoSpace commented Nov 8, 2026 •

Copy link
Copy Markdown

Purpose

  • FORCE_CONFIG_PATH is ignored in production builds. The production branch of public/index.html uses the build-time %FORCE_CONFIG_PATH% placeholder, so the value is fixed to whatever was set when the client was built (empty in the published images). This restores the runtime value that scripts/server.js already passes to build/index.pug.

Proposed Changes

  • [FIX] Use #{FORCE_CONFIG_PATH} in the production branch of public/index.html, matching the other values in that branch. The non-production branch is unchanged.

Issues

Testing

Built the client twice with npm run build from development at 63003cd, with and without this change, then ran scripts/server.js with NODE_ENV=production against PostGIS 16 (node:22-bookworm in Docker) and opened the page in a browser. The forced config was a copy of a Reference Mission blueprint served from public/.

Build FORCE_CONFIG_PATH Served mmgisglobal.FORCE_CONFIG_PATH Result
Without change set "" Forced file never requested; page calls missions and shows the mission list
With change set the configured path Forced file requested; its mission loads; no console errors
With change empty "" Page calls missions and shows the mission list, as before

An unset variable also renders as an empty string in the template.

I also reproduced the issue's scenario on the published ghcr.io/nasa-ammos/mmgis:development image (5.5.1-20261105), with NODE_ENV=production, HIDE_CONFIG=true, and a mission holding one config in the database and a different one in the forced file. The patched run bind-mounts a build/index.pug with this one line changed.

Image Opened /?mission=<name> Result
Published, unpatched page title from the database config Calls /api/configure/get; forced file never requested
Published, line patched page title from the forced file Forced file requested; /api/configure/get not called

Playwright with this change, using the .env from playwright-tests.yml and a production client build: tests/e2e/startup, tests/e2e/smoke.spec.js and tests/e2e/reference-mission.spec.js on chromium, 16 passed. The adjacent servers were not running. I did not run the rest of the suite.


Devin Review

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

Devin Review

Comment thread public/index.html
mmgisglobal.groups = "#{groups}";
mmgisglobal.NODE_ENV = "#{NODE_ENV}";
mmgisglobal.FORCE_CONFIG_PATH = "%FORCE_CONFIG_PATH%";
mmgisglobal.FORCE_CONFIG_PATH = "#{FORCE_CONFIG_PATH}";

ghost Nov 8, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Forced configuration paths with ampersands fail

When FORCE_CONFIG_PATH contains &, Pug inserts &amp; into the JavaScript string. loadConfigJson fetches the altered path, so the configured mission fails to load.

Learn more

Production builds convert this HTML into a Pug template, which escapes interpolated values as HTML. Script elements do not decode HTML entities, so an escaped character becomes part of the URL passed to loadConfigJson. This affects ampersands, apostrophes, and other escaped characters in an otherwise valid forced configuration path.

Example: With FORCE_CONFIG_PATH=public/R&D/config.json, the page sets the path to public/R&amp;D/config.json. The browser requests that encoded path rather than public/R&D/config.json, and the mission fails to load.

Recommended fix: Serialize the runtime value as a JavaScript string for the script context rather than HTML-escaping it. Account for the HTML script closing sequence when generating the string, and test paths containing & and apostrophes in a rendered production page.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

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.

[Bug]: FORCE_CONFIG_PATH ignored in production builds since #919 (5.0.15+)

1 participant