fix(web): derive rpc-path correctly for /web and /admin mounts #67

Merged
sameh-farouk merged 1 commit from development_sameh into development 2026-06-03 15:33:55 +00:00
Member

Problem

The collab web app's canvas and dashboard 404 on every RPC call (POST /hero_collab/web/rpc/rpc → 404), and the canvas shows a spurious "Who are you? Pick your identity" prompt even when the user is already logged into the chat view.

Root cause

rpc_path_from_base (in crates/hero_collab_admin/src/routes.rs) builds the rpc-path meta tag the browser uses for RPC. It only stripped a trailing /ui segment. After the ui.sockweb.sock rename, this binary serves on web.sock and hero_router forwards X-Forwarded-Prefix = /<service>/web. The /web suffix fell through the else branch unchanged, so the injected path became /<service>/web/rpc/rpc (404 — web.sock does not proxy RPC) instead of /<service>/rpc/rpc.

  • The chat view worked because it builds its URL as basePath + '/rpc'.
  • The canvas/dashboard read the rpc-path meta → every call 404'd.
  • The "Who are you?" prompt is a cascade: the canvas loads identity over RPC; the call failed, so it fell back to the identity picker.

Fix

Strip whichever trailing UI mount segment the router forwarded (/ui, /web, or /admin) before appending /rpc/rpc.

Verification (local, dev mode, behind hero_router)

  • Injected meta is now <meta name="rpc-path" content="/hero_collab/rpc/rpc"> (was /hero_collab/web/rpc/rpc)
  • POST /hero_collab/rpc/rpc200 through hero_router
  • Canvas loads with the logged-in identity; no "Who are you?" prompt

Bug present identically on main — will cherry-pick after this merges.

## Problem The collab web app's canvas and dashboard 404 on every RPC call (`POST /hero_collab/web/rpc/rpc → 404`), and the canvas shows a spurious **"Who are you? Pick your identity"** prompt even when the user is already logged into the chat view. ## Root cause `rpc_path_from_base` (in `crates/hero_collab_admin/src/routes.rs`) builds the `rpc-path` meta tag the browser uses for RPC. It only stripped a trailing `/ui` segment. After the `ui.sock` → `web.sock` rename, this binary serves on `web.sock` and hero_router forwards `X-Forwarded-Prefix = /<service>/web`. The `/web` suffix fell through the `else` branch unchanged, so the injected path became `/<service>/web/rpc/rpc` (404 — web.sock does not proxy RPC) instead of `/<service>/rpc/rpc`. - The **chat** view worked because it builds its URL as `basePath + '/rpc'`. - The **canvas/dashboard** read the `rpc-path` meta → every call 404'd. - The **"Who are you?"** prompt is a cascade: the canvas loads identity over RPC; the call failed, so it fell back to the identity picker. ## Fix Strip whichever trailing UI mount segment the router forwarded (`/ui`, `/web`, or `/admin`) before appending `/rpc/rpc`. ## Verification (local, dev mode, behind hero_router) - Injected meta is now `<meta name="rpc-path" content="/hero_collab/rpc/rpc">` (was `/hero_collab/web/rpc/rpc`) - `POST /hero_collab/rpc/rpc` → **200** through hero_router - Canvas loads with the logged-in identity; no "Who are you?" prompt Bug present identically on `main` — will cherry-pick after this merges.
`rpc_path_from_base` only stripped a trailing `/ui` segment when
building the `rpc-path` meta tag the browser uses for RPC. After the
`ui.sock` → `web.sock` rename, this binary serves on `web.sock` and
hero_router forwards `X-Forwarded-Prefix = /<service>/web`. The `/web`
suffix fell through the `else` branch unchanged, so the injected
rpc-path became `/<service>/web/rpc/rpc` — which 404s (web.sock does
not proxy RPC) — instead of `/<service>/rpc/rpc`.

The chat view happened to work (it builds its URL as basePath+'/rpc'),
but the canvas and dashboard read the rpc-path meta, so every canvas
RPC 404'd. That also surfaced as a spurious "Who are you? Pick your
identity" prompt on the canvas: identity is loaded over RPC, the call
failed, so the canvas fell back to the identity picker even when the
user was already logged into the chat app.

Fix: strip whichever trailing UI mount segment the router forwarded
(`/ui`, `/web`, or `/admin`) before appending `/rpc/rpc`.

Verified: injected meta is now `<meta name="rpc-path"
content="/hero_collab/rpc/rpc">` (was `/hero_collab/web/rpc/rpc`);
that path returns 200 through hero_router; canvas loads with the
logged-in identity.
sameh-farouk merged commit d780f4ef8d into development 2026-06-03 15:33:55 +00:00
sameh-farouk deleted branch development_sameh 2026-06-03 15:33:55 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
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_collab!67
No description provided.