Skip to content

fix(viewer): redirect /w/<wsid> to /w/<wsid>/ so assets load#187

Open
ivanmkc wants to merge 1 commit into
masterfrom
fix/workspace-trailing-slash
Open

fix(viewer): redirect /w/<wsid> to /w/<wsid>/ so assets load#187
ivanmkc wants to merge 1 commit into
masterfrom
fix/workspace-trailing-slash

Conversation

@ivanmkc

@ivanmkc ivanmkc commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Symptom

A workspace URL without the trailing slash — e.g. https://…/w/345926bf020d1034 — renders a blank page: status stuck on connecting…, no boards, empty canvas. Adding the slash (/w/345926bf020d1034/) works. (The demo only ever worked because it's linked as /w/demo/.)

Root cause

index.html references its assets relatively (<script type="module" src="viewer.js">). With no trailing slash the browser resolves viewer.js against /w/ → it fetches /w/viewer.js, which the SPA fallback answers with index.html (text/html). The browser refuses to execute an HTML response as a module (Failed to load module script: … MIME type "text/html"), so the entire client script never loads — leaving the static shell frozen at connecting….

[resp] 200 /w/viewer.js   (text/html — wrong)
[console.error] Failed to load module script: … MIME type of "text/html"

The /s/<token> share path already redirects the bare form to add the slash (server.ts) — the /w/<wsid> path was simply missing the same guard.

Fix

In the /w/<wsid> route, when the path is the bare workspace root with no trailing slash, 302/w/<wsid>/ (preserving any query string; the browser carries the #fragment across a fragment-less redirect). Mirrors the existing /s/<token> behavior.

Tests / verification

  • TDD (server-static.test.ts, written failing first): /w/<wsid>302 Location: /w/<wsid>/; the slashed root and asset paths are not redirected (still 200).
  • Full viewer suite green (621 passed).

Note

Independent of #186 (malformed-hash boot crash) and #185 (panes-density lint). All three are distinct "viewer broken page" fixes touching different code.

A workspace URL without the trailing slash (e.g. /w/345926bf020d1034) rendered
a blank "connecting…" page. index.html references its assets relatively
(<script src="viewer.js">), so without the slash the browser resolves them
against /w/ — fetching /w/viewer.js, which the SPA fallback answers with HTML.
The browser then refuses the module (MIME "text/html"), so the client script
never loads: status stuck "connecting…", no boards, blank canvas.

The /s/<token> share path already redirects the bare form to add the slash;
the /w/<wsid> path was missing the same guard. Add it (preserving any query;
the URL fragment is carried across a fragment-less redirect by the browser).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants