fix the prefix in UI #1
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
use skill /hero_web_prefix
make sure we use proper prefixes in admin interface e in ...._ui
Add `X-Forwarded-Prefix` support to the `my_compute_holo_ui` admin dashboard so it works correctly when served behind a reverse proxy at a sub-path (e.g., `/my_compute_holo_ui`).
Implementation Spec for Issue #1 — Fix the prefix in UI
Objective
Add
X-Forwarded-Prefixsupport to themy_compute_holo_uiadmin dashboard so it works correctly when served behind a reverse proxy at a sub-path (e.g.,/my_compute_holo_ui).Requirements
X-Forwarded-Prefixheader and makes it available to all handlersbase_pathvariable and prefixes all absolute URLsdashboard.js) usesBASE_PATHfor all fetch/location/WebSocket URLsbase_pathis""(unchanged behavior)Files to Modify
crates/my_compute_holo_ui/src/server.rs— Add BasePath middleware, update all template structs and handlerscrates/my_compute_holo_ui/templates/base.html— Prefix 11 static asset references, inject BASE_PATH JS variablecrates/my_compute_holo_ui/templates/partials/navbar.html— Prefix 3 navbar linkscrates/my_compute_holo_ui/templates/partials/sidebar.html— Prefix 5 sidebar linkscrates/my_compute_holo_ui/templates/index.html— Prefix ~8 inline JS hrefscrates/my_compute_holo_ui/templates/nodes.html— Prefix 1 inline JS hrefcrates/my_compute_holo_ui/static/js/dashboard.js— Prefix 9 hardcoded URL patternsImplementation Plan (10 Steps)
Step 1: Add BasePath middleware to server.rs
BasePath(String)structbase_path_middlewarefunction that readsX-Forwarded-PrefixheaderStep 2: Add
base_pathfield to all Askama template structsStep 3: Extract and pass
base_pathin all page handlersExtension(BasePath(base_path))and passes to templateStep 4: Update
base.htmltemplate<script>var BASE_PATH = "{{ base_path }}";</script>in headStep 5: Update
partials/navbar.htmlStep 6: Update
partials/sidebar.htmlStep 7: Update
index.htmlinline JS hrefsStep 8: Update
nodes.htmlinline JS hrefsStep 9: Update
dashboard.jsvar BASE_PATH = window.BASE_PATH || "";fallbackStep 10: Add unit test for middleware
Acceptance Criteria
X-Forwarded-Prefix, all static assets loadcargo buildcompiles without warningsTest Results
my_compute_holo_serverError Summary
E0432- Unresolved importhero_proc_sdk(1 occurrence)crates/my_compute_holo_server/src/cloud/server/../hero_proc_jobs.rs:9hero_proc_sdkis either not linked or not available at the expected path.E0282- Type annotations needed (17 occurrences)crates/my_compute_holo_server/src/cloud/server/../hero_proc_jobs.rsandrpc.rshero_proc_sdkimport. Once the import is fixed, most or all of these should resolve.Root Cause
The primary issue is that
hero_proc_sdkcannot be resolved. This is likely because:Cargo.toml, orhero_proc_sdkcrate API changed in a way that breaks the import path.Next Steps
hero_proc_sdkis listed as a dependency incrates/my_compute_holo_server/Cargo.tomlhero_procis referencedcargo testImplementation Summary
Changes Made
crates/my_compute_holo_ui/src/server.rsBasePathstruct andbase_path_middlewarethat readsX-Forwarded-Prefixheaderbase_path: Stringfield to all 5 Askama template structsBasePathfrom extensions and pass to templatestest_base_path_trimmingunit testcrates/my_compute_holo_ui/templates/base.html<script>var BASE_PATH = "{{ base_path }}";</script>in<head>{{ base_path }}crates/my_compute_holo_ui/templates/partials/navbar.html/,/settings,/openrpc.json) with{{ base_path }}crates/my_compute_holo_ui/templates/partials/sidebar.html/,/nodes,/vms,/admin,/settings) with{{ base_path }}crates/my_compute_holo_ui/templates/index.html{{ base_path }}BASE_PATHvariablecrates/my_compute_holo_ui/templates/nodes.htmlBASE_PATHvariablecrates/my_compute_holo_ui/static/js/dashboard.jsvar BASE_PATH = window.BASE_PATH || "";fallback/rpc,/explorer/rpc,/settings,/openrpc.json,/explorer-openrpc.json,/version,/console/, and 2 inline href stringsTest Results
cargo test -p my_compute_holo_ui: 6 passed, 0 failedmy_compute_holo_serverhas a pre-existing compilation issue (missinghero_proc_sdk) unrelated to these changesNotes
X-Forwarded-Prefixheader is present,base_pathis empty string — behavior is identical to beforeImplementation committed:
5f8120aBrowse:
5f8120a