Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: proxy bypass with WebSocket #18070

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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
Copy link

stackblitz bot commented Sep 10, 2024

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

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
None yet
Development

Successfully merging this pull request may close these issues.

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