Skip to content

Conversation

@sapphi-red
Copy link
Member

Description

#13218 made Vite's internal WebSocket connection to be able to be proxyed to other servers. But that made it impossible to proxy WebSocket connections while not proxying the internal WebSocket connection (See the table below).

Protocol Path Proxy? Remarks
HTTP /
HTTP /aaa
WS / WS connection to backend
WS /aaa Vite's internal WebSocket connection. This will be proxyed without this PR.

This PR makes proxyOptions.bypass to be called for WebSocket connections and make that possible.

An alternative is to change the WebSocket protocol to vite-hmr-${randomid} instead of vite-hmr and proxy all WS connections except connections with vite-hmr-${randomid}. Proxying other Vite server's WS connection is possible because other Vite server would have a different randomid.

fixes #17973

@sapphi-red sapphi-red added p2-edge-case Bug, but has workaround or limited in scope (priority) regression The issue only appears after a new release breaking change labels Sep 10, 2024
@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@patak-dev patak-dev changed the title feat: proxy bypass with WebSocket feat!: proxy bypass with WebSocket Oct 30, 2024
@patak-dev patak-dev enabled auto-merge (squash) October 30, 2024 08:02
@patak-dev patak-dev merged commit 3c9836d into vitejs:main Oct 30, 2024
@sapphi-red sapphi-red deleted the feat/proxy-bypass-ws branch October 30, 2024 09:08
sapphi-red added a commit to sapphi-red/vite that referenced this pull request Oct 30, 2024
bluwy pushed a commit that referenced this pull request Oct 30, 2024
moonlitusun pushed a commit to moonlitusun/vite that referenced this pull request May 25, 2025
moonlitusun pushed a commit to moonlitusun/vite that referenced this pull request May 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change p2-edge-case Bug, but has workaround or limited in scope (priority) regression The issue only appears after a new release

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

when I use proxy with ws and bypass, server can't up

3 participants