🤖 feat: support Coder path-app iframe embedding#3194
🤖 feat: support Coder path-app iframe embedding#3194ibetitsmike wants to merge 4 commits intomainfrom
Conversation
Audit: - backendBaseUrl now re-exports the shared parser. - RouterContext and App preserve the cached app-proxy prefix on browser history writes. - main.tsx and terminal popouts resolve service-worker.js and terminal.html through document.baseURI with the cached prefix. - terminal.html uses a relative terminal window module script so it stays under the proxy base path. - Grep found no raw browser-runtime /api, /auth, /orpc, /service-worker.js, or /terminal.html literals outside stories after the changes. Validation: - bun test src/common/appProxyBasePath.test.ts src/browser/utils/backendBaseUrl.test.ts - make typecheck
Support Coder app-proxy base paths across HTTP routing, WebSocket upgrades, generated SPA base hrefs, Scalar docs, session cookie paths, and OAuth URLs. Validation: - bun test src/node/orpc/server.test.ts src/browser/utils/backendBaseUrl.test.ts src/common/appProxyBasePath.test.ts - make typecheck - make lint
Use relative manifest and icon URLs so the server-injected base href keeps Coder path-app prefixes for HTML, manifest, and dynamic favicon updates.
|
@codex review
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 37af608cd4
ℹ️ 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".
|
@codex review
|
|
Codex Review: Didn't find any major issues. Keep it up! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Summary
Adds path-app iframe support for Mux when it is served behind a Coder app prefix such as
/@user/workspace/apps/mux/. Built assets, static web app metadata, API routes, docs, auth redirects, router paths, and WebSocket upgrades now resolve through the detected public prefix instead of assuming origin root.Background
Mux's production HTML injected
<base href="/" />, which caused relative Vite bundle paths to resolve from origin root. That breaks when Coder serves Mux under a path prefix inside an iframe. The backend also matched HTTP and WebSocket routes only at root paths, so deployments where the proxy forwards prefixed paths could miss/api,/orpc,/auth, and WS upgrade routes.Implementation
src/common/appProxyBasePath.tsto centralize Coder app-proxy path parsing and stripping.<base href>per request from forwarded headers or direct prefixed paths, with validated and escaped path values./orpc/ws,/browser/ws, and/desktop/ws.<base href>and manifest location.Validation
Before opening the PR:
make static-checkbun test src/common/appProxyBasePath.test.ts src/browser/utils/backendBaseUrl.test.ts src/node/orpc/server.test.tsmake typecheckmake lintdist/cli/index.js server --no-authsmoke checks:<base href="/" />.<base href="/@u/ws/apps/mux/" />./api/docsemits/@u/ws/apps/mux/api/spec.json./@u/ws/apps/mux/./@u/ws/apps/mux/.After Codex approval on head
52f9524bf4dbd6e1bea2d6eaab953b09b3b8e908:bun test src/common/appProxyBasePath.test.ts src/browser/utils/backendBaseUrl.test.ts src/node/orpc/server.test.tsmake static-checkmake builddist/cli/index.js server --no-auth:<base href="/" />.<base href="/@u/ws/apps/mux/" />.<base href="/@a/b/apps/mux/" />../?action=new.icon-192.png./api/spec.json:200./api/docsspec URL:/@u/ws/apps/mux/api/spec.json.200./@u/ws/apps/mux/scope.document.baseURI, manifest href, and favicon href all resolve under/@u/ws/apps/mux/./@u/ws/apps/mux/.Artifacts from local dogfood are under
dogfood-output/mux-path-app/.Review status
Codex initially flagged the PWA shortcut URL. The shortcut now uses
./?action=new, the review thread was resolved, and Codex approved the updated head. Required checks passed.Risks
The main risk is route rewriting affecting root-hosted deployments or normal app routes that contain
/apps/. The parser is anchored to Coder-shaped path-app prefixes, and tests cover root mode, direct-prefixed mode, forwarded-header mode, non-prefix/apps/paths, sequential tenant prefixes, origin validation, WebSocket upgrade normalization, docs URLs, and OAuth URL generation.Generated with
mux• Model:openai:gpt-5.5• Thinking:xhigh• Cost:$56.00