mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-04 08:25:26 +03:00
fix(dev): keep the page's Host on the Vite WebSocket proxy
b1108a9e made the panel reject a WebSocket upgrade whose Origin port
differs from the Host port. The dev proxy forwarded /ws with
changeOrigin, which rewrites Host to localhost:2053 while the browser
still sends Origin http://localhost:5173, so every upgrade was refused
with "request origin not allowed by Upgrader.CheckOrigin". Vite then
relayed that response to a socket the browser had already closed and
logged "ws proxy error: write EPIPE" on each reconnect, and live
updates never reached the dev server.
The /ws proxy now leaves Host alone, as a production reverse proxy
does. The HTTP proxies keep changeOrigin; they are not origin-checked.
This commit is contained in:
@@ -289,10 +289,11 @@ export default defineConfig({
|
||||
'^/(?:[^/]+/)?(login|logout|getTwoFactorEnable|csrf-token|sponsors|panel|server)(?:/|$)': makeBackendProxy(BACKEND_TARGET),
|
||||
'^/$': makeBackendProxy(BACKEND_TARGET),
|
||||
'^/[^/]+/$': makeBackendProxy(BACKEND_TARGET),
|
||||
// No changeOrigin: the panel rejects an upgrade whose Origin port differs
|
||||
// from the Host port, so Host must stay the dev server the page came from.
|
||||
'^/(?:[^/]+/)?ws$': {
|
||||
target: 'ws://localhost:2053',
|
||||
ws: true,
|
||||
changeOrigin: true,
|
||||
rewrite: rewriteToBackend,
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user