hero_router strips trailing slash, breaking iframe relative asset URLs #79

Closed
opened 2026-04-30 09:43:49 +00:00 by zaelgohary · 0 comments
Member

Symptom

Iframe-served services on hero_router 404 on cold loads. Example:

GET /hero_voice/ui/  → 301 → /hero_voice/ui
GET /hero_voice/ui   → 200 (HTML)
HTML: <script src="./app.js">
GET /hero_voice/app.js  → 404 (router treats `app.js` as a webname → looks for web_app.js.sock)

Hits every iframe island (voice, books, inspector, indexer, embedder, foundry, osis, proxy, biz). Latent for ~3 weeks because warm caches masked it; surfaces on hard refresh.

Root cause

Commit b4d1aa3 (consolidate hero_router crates) rewrote strip_trailing_slash from a transparent middleware URI rewrite to a 301 redirect (crates/hero_router/src/server/routes.rs:1898 trailing_slash_redirect). The redirect moves the browser to the slashless URL, breaking relative <script src="./app.js"> resolution.

Before After (broken)
middleware silently rewrote URI; browser stays at /hero_voice/ui/ 301 to /hero_voice/ui
./app.js/hero_voice/ui/app.js ./app.js/hero_voice/app.js ✗ → 404

Fix

Restore middleware-style internal rewrite, OR flip redirect to add trailing slash for /<service>/<webname> paths.

## Symptom Iframe-served services on hero_router 404 on cold loads. Example: ``` GET /hero_voice/ui/ → 301 → /hero_voice/ui GET /hero_voice/ui → 200 (HTML) HTML: <script src="./app.js"> GET /hero_voice/app.js → 404 (router treats `app.js` as a webname → looks for web_app.js.sock) ``` Hits every iframe island (voice, books, inspector, indexer, embedder, foundry, osis, proxy, biz). Latent for ~3 weeks because warm caches masked it; surfaces on hard refresh. ## Root cause Commit b4d1aa3 (consolidate hero_router crates) rewrote `strip_trailing_slash` from a transparent middleware URI rewrite to a 301 redirect (crates/hero_router/src/server/routes.rs:1898 `trailing_slash_redirect`). The redirect moves the browser to the slashless URL, breaking relative `<script src="./app.js">` resolution. | Before | After (broken) | |---|---| | middleware silently rewrote URI; browser stays at `/hero_voice/ui/` | 301 to `/hero_voice/ui` | | `./app.js` → `/hero_voice/ui/app.js` ✓ | `./app.js` → `/hero_voice/app.js` ✗ → 404 | ## Fix Restore middleware-style internal rewrite, OR flip redirect to add trailing slash for `/<service>/<webname>` paths.
zaelgohary removed their assignment 2026-04-30 09:45:51 +00:00
Sign in to join this conversation.
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_router#79
No description provided.