ReviewOS

stacks/rpx

Proxy WebSockets

#26
Closed chris opened this 10 days ago ·
10 days ago

Clear and concise description of the problem

It's needed for HMR Image

Suggested solution

  • automatically proxy wss requests

Alternative

No response

Additional context

No response

Validations

10 days ago

Implemented in ef6142a — WebSockets (and wss://) are now proxied transparently in every mode. 🎉

Previously only the multi-proxy/daemon paths upgraded WebSockets; the single-proxy path (rpx --from … --to …, the common dev case) used a plain fetch() forwarder with no websocket handler, so HMR upgrades were silently dropped. The single proxy now routes through the same shared handler the multi-proxy, single-port, and daemon paths use, which wires the upgrade + WebSocket pump.

This is what makes dev-server HMR work over HTTPS — Vite's wss:// reload socket is terminated by rpx and forwarded to the dev server's ws:// endpoint. No configuration needed:

rpx start --from localhost:5173 --to my-app.localhost

A request with Upgrade: websocket is accepted and piped to ws://<from><path> in both directions, wherever HTTP proxying works.

Covered by an end-to-end WebSocket proxy test (upgrade + bidirectional frame piping through the real handler) and documented in the README WebSocket section and the HMR & WebSockets docs.

Sign in to comment on this issue.