Commit 775c3d7
authored
🤖 fix: harden path-app shell loading (#3195)
> Mux worked on behalf of Mike.
## Summary
Absorbs the small path-app hardening pieces from #3184 on top of the
merged #3194 implementation. This keeps the existing server-side prefix
detection, direct prefixed route handling, Scalar rewriting, and
terminal popout path support intact.
## Background
#3194 made mux work under Coder path-app iframe URLs. #3184 had a few
defensive ideas worth keeping as a focused follow-up: tolerate slashless
app-root URLs, avoid stale service worker caches, and keep static shell
assets resolving when a proxy strips the app prefix without sending
forwarding headers.
## Implementation
- Uses the detected public base path when available, preserving absolute
prefixed base hrefs for Coder path-app requests.
- Falls back to a relative base href climb when no public prefix is
detected, so root hosting and stripped-prefix proxy paths both resolve
static assets from the app root.
- Injects a slashless app-root redirect script before the base tag only
for app-root shell responses, with a same-origin redirect target and a
double-slash path guard.
- Bumps the service worker cache name to `mux-v2` and precaches relative
shell URLs.
- Adds regression coverage for the exact Coder path shape with a token
query, for example `/@admin/<workspace>.main/apps/mux/?token=...`, plus
a double-slash redirect guard.
## Validation
- `bun test src/node/orpc/server.test.ts`
- `bun test src/common/appProxyBasePath.test.ts
src/browser/utils/backendBaseUrl.test.ts`
- `make static-check`
## Risks
Low to moderate. This touches SPA shell HTML generation, but keeps
detected Coder path-app base href behavior unchanged and adds tests for
relative deep-route fallback, slashless app-root handling, direct
prefixed requests, double-slash paths, and false-positive `/apps/`
paths.
---
_Generated with `mux` • Model: `openai:gpt-5.5` • Thinking: `xhigh` •
Cost: `$78.40`_
<!-- mux-attribution: model=openai:gpt-5.5 thinking=xhigh costs=78.40
-->1 parent f2a029d commit 775c3d7
3 files changed
Lines changed: 89 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
| 2 | + | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
158 | 165 | | |
159 | 166 | | |
160 | 167 | | |
| |||
231 | 238 | | |
232 | 239 | | |
233 | 240 | | |
234 | | - | |
| 241 | + | |
235 | 242 | | |
236 | 243 | | |
237 | 244 | | |
| |||
248 | 255 | | |
249 | 256 | | |
250 | 257 | | |
251 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
252 | 275 | | |
253 | 276 | | |
254 | 277 | | |
| |||
297 | 320 | | |
298 | 321 | | |
299 | 322 | | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
300 | 340 | | |
301 | 341 | | |
302 | 342 | | |
| |||
323 | 363 | | |
324 | 364 | | |
325 | 365 | | |
326 | | - | |
| 366 | + | |
327 | 367 | | |
328 | 368 | | |
329 | 369 | | |
| |||
477 | 517 | | |
478 | 518 | | |
479 | 519 | | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
480 | 523 | | |
481 | | - | |
482 | 524 | | |
483 | 525 | | |
484 | 526 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
127 | 134 | | |
128 | 135 | | |
129 | 136 | | |
130 | 137 | | |
131 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
132 | 145 | | |
133 | 146 | | |
134 | 147 | | |
135 | 148 | | |
136 | | - | |
| 149 | + | |
137 | 150 | | |
138 | 151 | | |
139 | 152 | | |
| |||
579 | 592 | | |
580 | 593 | | |
581 | 594 | | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
582 | 610 | | |
583 | 611 | | |
584 | | - | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
585 | 620 | | |
586 | 621 | | |
587 | 622 | | |
| |||
1545 | 1580 | | |
1546 | 1581 | | |
1547 | 1582 | | |
1548 | | - | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
1549 | 1586 | | |
1550 | 1587 | | |
1551 | 1588 | | |
| |||
0 commit comments