From e78baddda185da3a0f2d72bf7198c67647f56579 Mon Sep 17 00:00:00 2001 From: Ben Davis <45952064+bmdavis419@users.noreply.github.com> Date: Fri, 24 Jul 2026 23:42:23 -0700 Subject: [PATCH] fix: proxy websocket upgrades to the server in reverse-proxied dev MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With --public-url the browser is told to reach the server at the public origin, which is the Vite dev port. Vite forwarded /api, /.well-known and /attachments but nothing upgraded websockets, so the client's RPC socket at /ws was answered by Vite instead of the server and closed before it opened. Every RPC then failed and the app reported the server as not connected — "siva is not connected" on the provider dialog, which reads as a Hermes fault but is the whole transport being down. Loopback dev never hit this because the client talks to the server port directly; only the reverse-proxied path routes through Vite. Add a /ws rule with ws: true, and set ws: true on /api as well since it carries the Hermes gateway socket at /api/hermes-gateway/ws. Verified against the running dev server: a real websockets client now completes the upgrade through the proxy and gets a structured connection.rejected / enrollment-expired from the broker for a bogus token, where previously the connection was dropped before the handshake. Co-Authored-By: Claude Opus 5 (1M context) --- apps/web/vite.config.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/apps/web/vite.config.ts b/apps/web/vite.config.ts index aa4313243c..590aef7165 100644 --- a/apps/web/vite.config.ts +++ b/apps/web/vite.config.ts @@ -149,14 +149,28 @@ export default defineConfig(() => { target: devProxyTarget, changeOrigin: true, }, + // `ws: true` because /api carries the Hermes gateway socket at + // /api/hermes-gateway/ws alongside plain HTTP routes. "/api": { target: devProxyTarget, changeOrigin: true, + ws: true, }, "/attachments": { target: devProxyTarget, changeOrigin: true, }, + // The client's RPC socket. Without a forwarding rule the upgrade + // is answered by Vite rather than the server, so a browser told + // to use the public origin (`--public-url`) connects to the Vite + // port and every RPC fails — the whole app reports the server as + // not connected. Loopback dev never hit this because the client + // talks to the server port directly. + "/ws": { + target: devProxyTarget, + changeOrigin: true, + ws: true, + }, }, } : {}),