Problem
When WireMock GUI is served behind a reverse proxy under a sub-path (e.g. https://host/wiremock/__admin/gui, where the proxy strips the /wiremock prefix before forwarding to WireMock), the GUI fails to load and cannot communicate with the admin API.
This makes the GUI unusable in common deployment patterns (Kubernetes ingress path prefixes, API gateways, shared hosts) unless the deployer forks the project and rebuilds with custom paths.
Root cause
Two places hardcode a root-mount assumption:
1. Static assets (Vite build)
webapp/vite.config.ts sets base: '/__admin/gui/'. Vite bakes that absolute path into the built index.html:
<script src="/__admin/gui/assets/...">
<link href="/__admin/gui/assets/...">
When the page is loaded at https://host/wiremock/__admin/gui, the browser resolves these absolute paths against the host root and requests https://host/__admin/gui/assets/... — the /wiremock prefix is lost, so assets never route back through the proxy to WireMock.
2. API base URL (React app)
webapp/src/App.tsx has getDefaultBaseUrl() which returns window.location.origin (path stripped) whenever window.location.pathname.includes('/__admin'). Every WireMockClient request therefore goes to <origin>/__admin/..., again dropping any sub-path prefix.
Expected behavior
The GUI should work when served at any mount path:
- Root:
https://host/__admin/gui (current behavior, must remain unchanged)
- Prefixed:
https://host/wiremock/__admin/gui (proxy strips prefix; WireMock still sees /__admin/gui)
…with no deploy-time rebuild or fork required.
Proposed fix
-
Assets: Use relative asset references (e.g. Vite base: './') combined with a runtime <base href> computed from window.location.pathname up to and including /__admin/gui/, injected via a small inline script in index.html before the module script. This ensures ./assets/x.js resolves correctly for both root and prefixed mounts.
-
API base: In getDefaultBaseUrl(), when the path contains /__admin, derive the base as window.location.origin + <prefix> where <prefix> is window.location.pathname truncated just before /__admin. Example: /wiremock/__admin/gui → API base https://host/wiremock; /__admin/gui → https://host.
Preserve existing localStorage override and http://localhost:8080 fallback.
Impact
- Enables path-based reverse-proxy deployments without forking
- Fully backward-compatible for current root-mounted deployments
- Frontend-only change; no Java/server-side changes required
Problem
When WireMock GUI is served behind a reverse proxy under a sub-path (e.g.
https://host/wiremock/__admin/gui, where the proxy strips the/wiremockprefix before forwarding to WireMock), the GUI fails to load and cannot communicate with the admin API.This makes the GUI unusable in common deployment patterns (Kubernetes ingress path prefixes, API gateways, shared hosts) unless the deployer forks the project and rebuilds with custom paths.
Root cause
Two places hardcode a root-mount assumption:
1. Static assets (Vite build)
webapp/vite.config.tssetsbase: '/__admin/gui/'. Vite bakes that absolute path into the builtindex.html:When the page is loaded at
https://host/wiremock/__admin/gui, the browser resolves these absolute paths against the host root and requestshttps://host/__admin/gui/assets/...— the/wiremockprefix is lost, so assets never route back through the proxy to WireMock.2. API base URL (React app)
webapp/src/App.tsxhasgetDefaultBaseUrl()which returnswindow.location.origin(path stripped) wheneverwindow.location.pathname.includes('/__admin'). EveryWireMockClientrequest therefore goes to<origin>/__admin/..., again dropping any sub-path prefix.Expected behavior
The GUI should work when served at any mount path:
https://host/__admin/gui(current behavior, must remain unchanged)https://host/wiremock/__admin/gui(proxy strips prefix; WireMock still sees/__admin/gui)…with no deploy-time rebuild or fork required.
Proposed fix
Assets: Use relative asset references (e.g. Vite
base: './') combined with a runtime<base href>computed fromwindow.location.pathnameup to and including/__admin/gui/, injected via a small inline script inindex.htmlbefore the module script. This ensures./assets/x.jsresolves correctly for both root and prefixed mounts.API base: In
getDefaultBaseUrl(), when the path contains/__admin, derive the base aswindow.location.origin + <prefix>where<prefix>iswindow.location.pathnametruncated just before/__admin. Example:/wiremock/__admin/gui→ API basehttps://host/wiremock;/__admin/gui→https://host.Preserve existing
localStorageoverride andhttp://localhost:8080fallback.Impact