fix(webview): resolve a relative base against the document directory

rebaseRelativeBase resolved a relative <base> against the proxy root, so
a document served from a subdirectory of its dashboard (for example
/webview/<cap>/app/page.html with <base href="./">) pointed at
/webview/<cap>/ and loaded its assets one level too high. Pass the
request's wildcard path into rewriteHtml and resolve the base against
the document URL, which keeps the proxy root for the landing page.
This commit is contained in:
ArizeSky committed 2026-11-16 16:11:58 +08:00
1 parent 238853f96a
commit cc413afdd1
6 files changed
+66 -9

No files matched your search

+5 -3
View File
@@ -146,9 +146,11 @@ layers cooperate so a dashboard talking to its own backend just works:
1. `<base href>` handles relative URLs in the markup. A page that ships its own
**relative** base (`<base href="./">`, what a Vite build emits) has it resolved
against the proxy prefix first: the page's URL is masked a few paragraphs below,
a base is resolved against that URL, so `./` would otherwise point at Codeman's
root and 404 every module script behind an otherwise-painted page.
against the document's own directory inside the proxy prefix first, so a
document at `/webview/<cap>/app/page.html` gets `/webview/<cap>/app/` rather
than the proxy root: the page's URL is masked a few paragraphs below, a base is
resolved against that URL, so `./` would otherwise point at Codeman's root and
404 every module script behind an otherwise-painted page.
2. Attribute rewriting handles root-absolute `src`/`href`/`action` in the page the
proxy serves — and root-absolute dynamic `import("/...")` specifiers in the
initial HTML. The import is the one URL no other layer can reach: `<base>` does