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

Merged
merged 2 commits into from
Oct 30, 2024

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.

@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
15 checks passed
@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
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