Dashboard's path-based mux URL hits a 404: '/ao-terminal-mux' has no upgrade handler
Summary
packages/web/src/providers/MuxProvider.tsx:56-79 constructs wss://hostname/ao-terminal-mux for the dashboard's mux WebSocket whenever the dashboard is served on a standard port (HTTPS 443, HTTP 80, or empty loc.port):
function buildMuxWsUrl(runtimeConfig) {
// …
// Port-less or standard ports: use path-based routing (reverse proxy expected)
if (loc.port === "" || loc.port === "443" || loc.port === "80") {
return `${protocol}//${loc.hostname}/ao-terminal-mux`;
}
// …
}
This is the path-based-routing branch — intended for deployments fronted by a reverse proxy with a public hostname. But nothing on the server side recognizes that path. direct-terminal-ws.ts:67 only matches pathname === "/mux" for upgrades, and Next.js (which receives the request on PORT) doesn't handle WS upgrades at all — the request falls through to its catch-all 404 page.
Result: every reverse-proxied HTTPS deployment that lets the dashboard's auto-detection take effect breaks. Terminal panes hang at "Connecting…" forever. The operator has to either:
- Configure their proxy to do path rewriting (
/ao-terminal-mux→/mux), which many proxies can't do (cloudflared notably) or require migrating off a managed config to do - Or expose
DIRECT_TERMINAL_PORTthrough the proxy on a separate subdomain/port and setTERMINAL_WS_PATH
Both are operationally annoying and undiscoverable — the standard-port branch silently assumes proxy capabilities that may not exist.
Repro
- Deploy AO behind any HTTPS reverse proxy with a single hostname → PORT mapping (e.g.
cloudflared tunnel runwithingress: [{hostname, service: http://localhost:8094}]). - Open the dashboard, spawn an orchestrator, click the session.
- Browser DevTools → Network → filter WS → see the
/ao-terminal-muxupgrade get HTTP 404 from Next.js (x-nextjs-prerender: 1on the response). - Terminal pane stays at "Connecting…".
Proposed (minimal)
Have direct-terminal-ws.ts accept /ao-terminal-mux as an alias for /mux. Then path-capable proxies (cloudflared, nginx, Caddy) just route /ao-terminal-mux → DIRECT_TERMINAL_PORT with no rewrite, and the existing dashboard JS works as-is. One-line change in the upgrade allow-list.
For proxies that can't even do path-based routing to a second port, see issue addressed in #1757's third commit (AO_PATH_BASED_MUX opt-in).
PR addressing this: #1757 (commit 279f2caf)
@prod-blip new issue from a non-collaborator.
Hi @thapecroth , thanks for filing this, it is really detailed and useful. I'm a contributor on AO and trying to get a sense of how it's working for folks using it in real workflows. Would love to hear a bit more about your experience and happy to hop on a quick 15-min call if that's easier. Here’s my calendly link https://calendly.com/atulpandey-iift1618/30min
Also, the contributors meet on Discord every day at 10pm IST: https://discord.gg/6KgeUjbe — drop in if you're around, good place to see what's being worked on and shape direction directly.