Skip to content

🤖 fix: harden path-app shell loading#3195

Merged
ibetitsmike merged 1 commit intomainfrom
mike/path-app-hardening
Apr 26, 2026
Merged

🤖 fix: harden path-app shell loading#3195
ibetitsmike merged 1 commit intomainfrom
mike/path-app-hardening

Conversation

@ibetitsmike
Copy link
Copy Markdown
Contributor

@ibetitsmike ibetitsmike commented Apr 26, 2026

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

@ibetitsmike
Copy link
Copy Markdown
Contributor Author

@codex review

Mux worked on behalf of Mike.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike ibetitsmike force-pushed the mike/path-app-hardening branch from 286c78a to 0953181 Compare April 26, 2026 10:14
@ibetitsmike
Copy link
Copy Markdown
Contributor Author

@codex review

Mux worked on behalf of Mike.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 09531819d5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node/orpc/server.ts Outdated
Add relative base href fallback for request paths without a detected public prefix, inject a slashless app-root redirect before the base tag, and bump the service worker cache to clear stale root-cached shells.

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

---

_Generated with `mux` • Model: `openai:gpt-5.5` • Thinking: `xhigh` • Cost: `8.40`_

<!-- mux-attribution: model=openai:gpt-5.5 thinking=xhigh costs=78.40 -->
@ibetitsmike ibetitsmike force-pushed the mike/path-app-hardening branch from 0953181 to 0e41674 Compare April 26, 2026 10:23
@ibetitsmike
Copy link
Copy Markdown
Contributor Author

@codex review

Mux worked on behalf of Mike.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ibetitsmike ibetitsmike added this pull request to the merge queue Apr 26, 2026
Merged via the queue into main with commit 775c3d7 Apr 26, 2026
24 checks passed
@ibetitsmike ibetitsmike deleted the mike/path-app-hardening branch April 26, 2026 14:25
mux-bot Bot added a commit that referenced this pull request Apr 26, 2026
The new helper added in #3195 was a 1-line shim around
`getPathnameFromRequestUrl(req.url)` used in only two adjacent functions
(`shouldInjectSlashlessRootRedirect` and `getPublicBaseHref`). The
existing `getPathnameFromRequestUrl` already conveys the intent, and the
two callsites read clearly without the extra layer.

Behavior-preserving: each callsite continues to compute the same pathname
(or null) it did before. All 52 tests in src/node/orpc/server.test.ts
continue to pass.
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.

1 participant