fix(viewer): redirect /w/<wsid> to /w/<wsid>/ so assets load#187
Open
ivanmkc wants to merge 1 commit into
Open
fix(viewer): redirect /w/<wsid> to /w/<wsid>/ so assets load#187ivanmkc wants to merge 1 commit into
ivanmkc wants to merge 1 commit into
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Symptom
A workspace URL without the trailing slash — e.g.
https://…/w/345926bf020d1034— renders a blank page: status stuck onconnecting…, 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.htmlreferences its assets relatively (<script type="module" src="viewer.js">). With no trailing slash the browser resolvesviewer.jsagainst/w/→ it fetches/w/viewer.js, which the SPA fallback answers withindex.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 atconnecting….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#fragmentacross a fragment-less redirect). Mirrors the existing/s/<token>behavior.Tests / verification
server-static.test.ts, written failing first):/w/<wsid>→302 Location: /w/<wsid>/; the slashed root and asset paths are not redirected (still200).Note
Independent of #186 (malformed-hash boot crash) and #185 (panes-density lint). All three are distinct "viewer broken page" fixes touching different code.