fix(ui): resolve path issues when served behind hero_router #14

Merged
mahmoud merged 7 commits from development_fix_ui_path_resolution into development 2026-04-21 08:14:46 +00:00
Member

Summary

  • Add dynamic base path resolution using X-Forwarded-Prefix header and <meta name="base-path"> tag injection
  • Add missing /rpc proxy route to the UI Axum server
  • Fix all hardcoded URL references in JavaScript (RPC, WebSocket, audio files, transforms, health checks)

Closes #10

Changes

  • main.rs: Added BasePath struct, updated middleware to extract X-Forwarded-Prefix, added /rpc route with rpc_handler, modified serve_static to inject base-path meta tag into index.html
  • app.js: Added BASE constant derived from meta tag with pathname fallback, prefixed all URL references (RPC, WebSocket, audio files, transforms) with BASE
  • index.html: Changed script tag to ./app.js for explicit relative resolution, added base-path reading to inline health-check script, prefixed fetch() calls with base path

Test Results

  • Build: pass
  • Tests: 13 passed, 0 failed
    image
## Summary - Add dynamic base path resolution using `X-Forwarded-Prefix` header and `<meta name="base-path">` tag injection - Add missing `/rpc` proxy route to the UI Axum server - Fix all hardcoded URL references in JavaScript (RPC, WebSocket, audio files, transforms, health checks) ## Related Issue Closes https://forge.ourworld.tf/lhumina_code/hero_voice/issues/10 ## Changes - **main.rs**: Added `BasePath` struct, updated middleware to extract `X-Forwarded-Prefix`, added `/rpc` route with `rpc_handler`, modified `serve_static` to inject base-path meta tag into `index.html` - **app.js**: Added `BASE` constant derived from meta tag with pathname fallback, prefixed all URL references (RPC, WebSocket, audio files, transforms) with `BASE` - **index.html**: Changed script tag to `./app.js` for explicit relative resolution, added base-path reading to inline health-check script, prefixed `fetch()` calls with base path ## Test Results - Build: pass - Tests: 13 passed, 0 failed ![image](/attachments/2c1766f0-94c5-49ec-b022-b5b7342fd731)
308 KiB
fix(ui): resolve path issues when served behind hero_router
Some checks failed
Build / build (pull_request) Failing after 23s
aafc7fae9f
#10
salmaelsoly changed title from fix(ui): resolve path issues when served behind hero_router to WIP: fix(ui): resolve path issues when served behind hero_router 2026-04-19 08:40:25 +00:00
fix(ci): install libclang-dev and libespeak-ng-dev for bindgen
Some checks failed
Build / build (pull_request) Failing after 57s
b4fae2b502
#10
salmaelsoly force-pushed development_fix_ui_path_resolution from b4fae2b502
Some checks failed
Build / build (pull_request) Failing after 57s
to c376ad400c
Some checks failed
Build / build (pull_request) Has been cancelled
2026-04-19 09:17:23 +00:00
Compare
salmaelsoly force-pushed development_fix_ui_path_resolution from c376ad400c
Some checks failed
Build / build (pull_request) Has been cancelled
to 033824d61d
All checks were successful
Build / build (pull_request) Successful in 7m36s
2026-04-19 09:17:36 +00:00
Compare
fix: resolve all clippy warnings across workspace
Some checks failed
Build / build (pull_request) Failing after 3m40s
1072af1f30
#10
salmaelsoly force-pushed development_fix_ui_path_resolution from 1072af1f30
Some checks failed
Build / build (pull_request) Failing after 3m40s
to 242cb89c91
All checks were successful
Build / build (pull_request) Successful in 8m36s
2026-04-19 09:36:35 +00:00
Compare
fix(ui): rpc url and base path
All checks were successful
Build / build (pull_request) Successful in 7m39s
e36b81e8d6
salmaelsoly changed title from WIP: fix(ui): resolve path issues when served behind hero_router to fix(ui): resolve path issues when served behind hero_router 2026-04-19 10:12:47 +00:00
Member

Tested, working when I opened hero voice UI from hero router

image

Tested, working when I opened hero voice UI from hero router ![image](/attachments/e02f24c7-51da-4ac1-b5ed-917c9a6fbc43)
fix(ui): improve base path handling and add HTML escaping for attributes
All checks were successful
Build / build (pull_request) Successful in 5m29s
9f57781764
mahmoud merged commit 5f00bc92fb into development 2026-04-21 08:14:46 +00:00
mahmoud deleted branch development_fix_ui_path_resolution 2026-04-21 08:14:50 +00:00
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_voice!14
No description provided.