[router] UI templates hardcode bare /rpc & /openrpc.json — API Docs + Admin (and home dashboard) 404 after the /api/{domain}/ migration #124

Closed
opened 2026-06-15 09:05:10 +00:00 by sameh-farouk · 1 comment
Member

Symptom

Multiple router UI tabs fail because their browser RPC/spec calls hit dead paths. Two visible examples (screenshots below):

  • API Docs → "Failed to load openrpc.json: HTTP 404"
  • Admin → "Failed to load access state: Cannot read properties of undefined (reading 'client_ip')" — the RPC call returns nothing, so who.client_ip throws; "Your address" stays blank.

Root cause (systemic)

BASE_PATH resolves to / for the direct router UI, and the templates fetch bare paths that no longer exist — the router now serves RPC/specs domain-scoped under /api/main/:

bare path the UI uses result correct path
POST /rpc 404 /api/main/rpc (200)
GET /openrpc.json 404 /api/main/openrpc.json (200)

Affected call sites (7 across 4 files)

  • templates/api.html:213fetch(BASE_PATH + 'openrpc.json') (+ link, line 26) → API Docs
  • templates/admin.html:148fetch(BASE_PATH + "rpc")Admin access state
  • templates/base.html:837, 856, 985fetch(BASE_PATH + 'rpc') → home dashboard / nav RPC
  • static/js/dashboard.js:8fetch(BASE_PATH + 'rpc')

Note: dashboard.js already uses the domain-scoped BASE_PATH + 'api/main/events' for SSE — so the codebase is inconsistent; these RPC/spec sites were simply missed in the /api/{domain}/ migration.

Fix

Point these at the domain-scoped paths (/api/main/rpc, /api/main/openrpc.json). The templates already display POST /api/main/rpc, so main is the known domain. Same class as hero_lib #151 / #153.

The proper fix may prefer to discover the domain (multi-domain-aware) rather than hardcode main, in line with the per-domain OpenRPC direction.

Confirmed on latest development (cb1d53f); none of the recent multi-domain commits touched these call sites.

Screenshots

API Docs:

api-docs 404

Admin:

admin client_ip

## Symptom Multiple router UI tabs fail because their browser RPC/spec calls hit dead paths. Two visible examples (screenshots below): - **API Docs** → "Failed to load openrpc.json: HTTP 404" - **Admin** → "Failed to load access state: Cannot read properties of undefined (reading 'client_ip')" — the RPC call returns nothing, so `who.client_ip` throws; "Your address" stays blank. ## Root cause (systemic) `BASE_PATH` resolves to `/` for the direct router UI, and the templates fetch **bare** paths that no longer exist — the router now serves RPC/specs **domain-scoped** under `/api/main/`: | bare path the UI uses | result | correct path | |---|---|---| | `POST /rpc` | **404** | `/api/main/rpc` (200) | | `GET /openrpc.json` | **404** | `/api/main/openrpc.json` (200) | ## Affected call sites (7 across 4 files) - `templates/api.html:213` — `fetch(BASE_PATH + 'openrpc.json')` (+ link, line 26) → **API Docs** - `templates/admin.html:148` — `fetch(BASE_PATH + "rpc")` → **Admin** access state - `templates/base.html:837, 856, 985` — `fetch(BASE_PATH + 'rpc')` → home dashboard / nav RPC - `static/js/dashboard.js:8` — `fetch(BASE_PATH + 'rpc')` Note: `dashboard.js` already uses the domain-scoped `BASE_PATH + 'api/main/events'` for SSE — so the codebase is inconsistent; these RPC/spec sites were simply missed in the `/api/{domain}/` migration. ## Fix Point these at the domain-scoped paths (`/api/main/rpc`, `/api/main/openrpc.json`). The templates already display `POST /api/main/rpc`, so `main` is the known domain. Same class as hero_lib #151 / #153. *The proper fix may prefer to discover the domain (multi-domain-aware) rather than hardcode `main`, in line with the per-domain OpenRPC direction.* Confirmed on latest `development` (`cb1d53f`); none of the recent multi-domain commits touched these call sites. ## Screenshots **API Docs:** ![api-docs 404](https://forge.ourworld.tf/attachments/aabe4c42-30d4-4ea2-b60d-01b7cc02ffc5) **Admin:** ![admin client_ip](https://forge.ourworld.tf/attachments/2dbe168a-c3af-4c35-b34e-4d6b74efd742)
mahmoud self-assigned this 2026-06-15 09:07:36 +00:00
mahmoud added this to the ACTIVE project 2026-06-15 09:07:39 +00:00
mahmoud added this to the now milestone 2026-06-15 09:07:42 +00:00
Owner

Fixed on development (e42a1f9). Repointed all 8 bare call sites to the domain-scoped control plane (/api/main/rpc, /api/main/openrpc.json) across base.html, api.html, admin.html, partials/service.html, and static/js/dashboard.js (the 8th was service.htmlrouter.agent.models, not in the original list). Verified live: /api/main/openrpc.json → 200, POST /api/main/rpc → valid envelope; bare paths remain 404 as expected. Hardcoding main is correct here since the router control plane is single-domain; the multi-domain viewer keeps its domain selector.

Fixed on `development` (`e42a1f9`). Repointed all 8 bare call sites to the domain-scoped control plane (`/api/main/rpc`, `/api/main/openrpc.json`) across `base.html`, `api.html`, `admin.html`, `partials/service.html`, and `static/js/dashboard.js` (the 8th was `service.html` → `router.agent.models`, not in the original list). Verified live: `/api/main/openrpc.json` → 200, `POST /api/main/rpc` → valid envelope; bare paths remain 404 as expected. Hardcoding `main` is correct here since the router control plane is single-domain; the multi-domain viewer keeps its domain selector.
Sign in to join this conversation.
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_router#124
No description provided.