Skip to content

fix(webui): read REST API URL at runtime instead of build time - #585

Merged
uhurusurfa merged 1 commit into
OpenAS2:masterfrom
igwtech:fix/webui-runtime-restapi-url
Aug 7, 2026
Merged

fix(webui): read REST API URL at runtime instead of build time#585
uhurusurfa merged 1 commit into
OpenAS2:masterfrom
igwtech:fix/webui-runtime-restapi-url

Conversation

@GreicodexJM

Copy link
Copy Markdown
Contributor

Problem

VUE_APP_RESTAPI_URL is read via process.env in LoginScreen.vue, which Vue CLI
inlines as a string literal at compile time. The REST API URL is therefore baked
into the JS bundle when the image is built.

The practical effect is that a published Dockerfile_WebUI image only ever works
against whatever host it was built for. It defaults to http://localhost:8080, so
anyone pulling a prebuilt WebUI image has to rebuild it from source just to point
the UI at their own server. That makes the WebUI image hard to distribute.

Change

Serve the value from a small config.js loaded before the app bundle, and
regenerate that file at container start from an environment variable.

  • WebUI/public/config.js — sets window.__OPENAS2_CONFIG__
  • WebUI/docker/40-openas2-config.sh — rewrites it from OPENAS2_RESTAPI_URL.
    Dropped into /docker-entrypoint.d/, which the official nginx image already
    sources, so no ENTRYPOINT override is needed.
  • LoginScreen.vue — resolution order: runtime config → build-time
    VUE_APP_RESTAPI_URLhttp://127.0.0.1:8443/api
  • docker-compose.yml — build args become runtime environment

Default is http://localhost:8443/api, matching the compose REST API port.

Backwards compatible. The build arg still works and still wins over the
compiled default, so existing build pipelines are unaffected. The only behaviour
change is that OPENAS2_RESTAPI_URL, when set, takes precedence.

Verification

Built the image and ran it both ways:

$ docker run -d -p 8080:80 openas2-webui
$ curl -s localhost:8080/config.js
window.__OPENAS2_CONFIG__ = { restApiUrl: "http://localhost:8443/api" };

$ docker run -d -p 8080:80 -e OPENAS2_RESTAPI_URL=https://as2.example.org/api openas2-webui
$ curl -s localhost:8080/config.js
window.__OPENAS2_CONFIG__ = { restApiUrl: "https://as2.example.org/api" };

Also confirmed __OPENAS2_CONFIG__ is present in both the modern and legacy
compiled bundles, so the app actually reads it rather than the file merely being
served.

The change was additionally applied across the v4.1.0–v4.9.0 tags and built for
each; the anchors it touches are unchanged across that range.

Note

The URL is interpolated into a JS string literal, so the entrypoint escapes
backslashes and double quotes. It is an operator-supplied value, not user input.

The API URL was inlined into the JS bundle by Vue CLI, so a published
image only ever worked against whatever host it was built for. Serve the
value from config.js instead, regenerated at container start from
OPENAS2_RESTAPI_URL (default http://localhost:8443/api) by a script in
nginx's /docker-entrypoint.d.

One image now serves any deployment. The build-time VUE_APP_RESTAPI_URL
still works as a fallback, so existing builds are unaffected.
@GreicodexJM
GreicodexJM force-pushed the fix/webui-runtime-restapi-url branch from 860f711 to d14a57a Compare August 7, 2026 14:16
@uhurusurfa
uhurusurfa merged commit 5b00aa9 into OpenAS2:master Aug 7, 2026
11 checks passed
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