@camstack/server 1.2.238 → 1.2.240
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/static/spa-mount.js +11 -2
- package/package.json +1 -1
|
@@ -92,6 +92,13 @@ function parseForwardedPrefix(value) {
|
|
|
92
92
|
* `<head>` — `<base>` must precede every URL-bearing element to apply to it.
|
|
93
93
|
* A shell with no `<head>` is returned untouched: guessing where to put a
|
|
94
94
|
* `<base>` is worse than serving the root shell.
|
|
95
|
+
*
|
|
96
|
+
* The `<base>` is written for EVERY request, mount or not. The shell's assets
|
|
97
|
+
* are relative (`vite base: './'`) and the SPA serves the same shell at every
|
|
98
|
+
* depth, so without a base `/devices` asks for `/devices/assets/…` and every
|
|
99
|
+
* chunk 404s — the admin UI was broken on every deep route the moment the
|
|
100
|
+
* relative build shipped, and only the root worked (operator, 2026-09-07).
|
|
101
|
+
* A root mount is therefore `<base href="/">`, not "no base at all".
|
|
95
102
|
*/
|
|
96
103
|
function injectSpaMount(html, prefix) {
|
|
97
104
|
const match = /<head(?:\s[^>]*)?>/i.exec(html);
|
|
@@ -118,6 +125,8 @@ async function sendSpaShell(reply, indexPath, headers) {
|
|
|
118
125
|
// A redeploy replaced the dist under us; the next request finds the new one.
|
|
119
126
|
return reply.status(503).send({ error: 'Admin UI shell unavailable' });
|
|
120
127
|
}
|
|
121
|
-
|
|
122
|
-
|
|
128
|
+
// `''` is the root mount: `injectSpaMount` writes `<base href="/">`, which a
|
|
129
|
+
// relative-asset shell needs at every depth. Never "no base".
|
|
130
|
+
const prefix = parseForwardedPrefix(headers[exports.FORWARDED_PREFIX_HEADER]) ?? '';
|
|
131
|
+
return reply.type('text/html').send(injectSpaMount(html, prefix));
|
|
123
132
|
}
|