fix: proxy-compatible URLs for hero_compute_ui (#33) #47

Closed
mik-tf wants to merge 1 commit from development_mik into development
Owner

Summary

  • All CSS/JS/link references used absolute paths (/css/, /js/, /rpc) which break behind hero_proxy at /hero_compute_ui/
  • Added BASE_PATH JS detection + <base> tag pattern (same as other Hero UIs)
  • Changed asset refs to relative, prefixed fetch() calls with BP variable
  • 4 files, 38 additions, 24 deletions

Test plan

  • Verify CSS loads at http://localhost:9090/hero_compute_ui/ (was 404)
  • Verify RPC calls work behind proxy (dashboard, node status)
  • Verify navigation links work (sidebar, navbar)

Ref: lhumina_code/home#33

## Summary - All CSS/JS/link references used absolute paths (`/css/`, `/js/`, `/rpc`) which break behind hero_proxy at `/hero_compute_ui/` - Added `BASE_PATH` JS detection + `<base>` tag pattern (same as other Hero UIs) - Changed asset refs to relative, prefixed fetch() calls with `BP` variable - 4 files, 38 additions, 24 deletions ## Test plan - [ ] Verify CSS loads at `http://localhost:9090/hero_compute_ui/` (was 404) - [ ] Verify RPC calls work behind proxy (dashboard, node status) - [ ] Verify navigation links work (sidebar, navbar) Ref: https://forge.ourworld.tf/lhumina_code/home/issues/33
fix: proxy-compatible URLs for hero_compute_ui behind hero_proxy (#33)
Some checks failed
Test / test (push) Failing after 50s
Test / test (pull_request) Failing after 48s
7488023825
All CSS/JS/link references used absolute paths (/css/, /js/, /rpc)
which break behind hero_proxy at /hero_compute_ui/. Fixed by:

- Added BASE_PATH JS detection + <base> tag in base.html <head>
- Changed all asset refs from absolute to relative (css/, js/)
- Changed nav links from absolute (/) to relative (./, nodes, etc.)
- Prefixed all fetch() calls in dashboard.js with BP variable

lhumina_code/home#33

Signed-off-by: mik-tf
mik-tf force-pushed development_mik from 7488023825
Some checks failed
Test / test (push) Failing after 50s
Test / test (pull_request) Failing after 48s
to d66b95e486
All checks were successful
Test / test (pull_request) Successful in 1m26s
Test / test (push) Successful in 1m47s
2026-03-28 05:46:01 +00:00
Compare
Owner

@mik-tf A few issues with this PR before we can merge:

  1. Why /hero_compute_ui/ as base path?

The UI is served on port 9001 at /. There's no reason to change the base URL to /hero_compute_ui/. If you're trying to support hero_proxy, the server already has HERO_COMPUTE_BASE_PATH env var for this, the base path should come from the server via /api/config, not be guessed from the URL with a regex.

  1. explorerRpc() not updated
function rpc(method, params) { return _rpcPost(BP + "rpc", method, params); }
function explorerRpc(method, params) { return _rpcPost("/explorer/rpc", method, params); }  // ← still hardcoded

explorerRpc is still using an absolute path. Explorer mode will break behind the proxy.

  1. Console WebSocket path not updated

The console connects via ws://host/console/{vm_sid}, this isn't prefixed with BP anywhere. Console will break behind the proxy.

  1. tag is fragile

Adding a dynamic tag changes how ALL relative URLs resolve on the page, WebSocket URLs, anchor href="#", image refs, etc. This is known to cause hard-to-debug issues. A safer approach is to keep CSS/JS as absolute paths and only prefix fetch() calls with a server-provided base path variable.

  1. Needs rebase

This PR is based on old code; it still has chvm_version references. We've renamed all chvmmy_hypervisor on development. Please rebase.

  1. Regex assumes a binary name in URL
var m = location.pathname.match(/^\/(hero_\w+_ui)(\/|$)/);

This only works if the proxy path matches the binary name. If someone mounts it at /cloud/ or /compute/, it breaks. Use the server-provided config instead.

Recommendation: Close this PR. If proxy support is needed, we should implement it properly using the existing HERO_COMPUTE_BASE_PATH env var injected via /api/config, not URL guessing.

@mik-tf A few issues with this PR before we can merge: 1. Why /hero_compute_ui/ as base path? The UI is served on port 9001 at /. There's no reason to change the base URL to /hero_compute_ui/. If you're trying to support hero_proxy, the server already has `HERO_COMPUTE_BASE_PATH` env var for this, the base path should come from the server via /api/config, not be guessed from the URL with a regex. 2. explorerRpc() not updated ```rust function rpc(method, params) { return _rpcPost(BP + "rpc", method, params); } function explorerRpc(method, params) { return _rpcPost("/explorer/rpc", method, params); } // ← still hardcoded ``` explorerRpc is still using an absolute path. Explorer mode will break behind the proxy. 3. Console WebSocket path not updated The console connects via ws://host/console/{vm_sid}, this isn't prefixed with BP anywhere. Console will break behind the proxy. 4. <base> tag is fragile Adding a dynamic <base> tag changes how ALL relative URLs resolve on the page, WebSocket URLs, anchor href="#", image refs, etc. This is known to cause hard-to-debug issues. A safer approach is to keep CSS/JS as absolute paths and only prefix `fetch()` calls with a server-provided base path variable. 5. Needs rebase This PR is based on old code; it still has chvm_version references. We've renamed all `chvm` → `my_hypervisor` on development. Please rebase. 6. Regex assumes a binary name in URL ```rust var m = location.pathname.match(/^\/(hero_\w+_ui)(\/|$)/); ``` This only works if the proxy path matches the binary name. If someone mounts it at `/cloud/` or `/compute/`, it breaks. Use the server-provided config instead. Recommendation: Close this PR. If proxy support is needed, we should implement it properly using the existing `HERO_COMPUTE_BASE_PATH` env var injected via /api/config, not URL guessing.
mahmoud closed this pull request 2026-04-07 08:55:44 +00:00
All checks were successful
Test / test (pull_request) Successful in 1m26s
Test / test (push) Successful in 1m47s

Pull request closed

Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_compute!47
No description provided.