fix: forward the browser's host from the dev proxy to the backend (#12818)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
hugocasa
2026-12-02 16:28:03 +01:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 047e1530c0
commit 0dd0a78384
+17 -2
View File
@@ -330,6 +330,21 @@ const cookieDomain = isolateDevAuth ? '' : 'localhost'
// with it so that one worktree's login does not stand for another's session.
const sessionHintCookie = isolateDevAuth ? `${authCookie}_hint` : 'wm_session'
// `changeOrigin` rewrites Host to the backend's, so pass on the host the browser addressed:
// over plain http to a LAN or Tailscale address there is no Sec-Fetch-Site, and the backend's
// cross-site check (request_site.rs) then matches Origin against the hosts it can see.
function forwardHost(proxy) {
proxy.on('proxyReq', (proxyReq, req) => {
if (req.headers.host && !req.headers['x-forwarded-host'])
proxyReq.setHeader('x-forwarded-host', req.headers.host)
})
}
function configureApiProxy(proxy) {
forwardHost(proxy)
isolateAuthCookie(proxy)
}
function isolateAuthCookie(proxy) {
if (!isolateDevAuth) return
proxy.on('proxyReq', (proxyReq, req) => {
@@ -454,7 +469,7 @@ const config = {
target: remoteUrl,
changeOrigin: true,
cookieDomainRewrite: cookieDomain,
configure: isolateAuthCookie
configure: configureApiProxy
},
'^/api/w/[^/]+/s3_proxy/.*': {
target: remoteUrl,
@@ -474,7 +489,7 @@ const config = {
target: remoteUrl,
changeOrigin: true,
cookieDomainRewrite: cookieDomain,
configure: isolateAuthCookie
configure: configureApiProxy
},
'^/ws/.*': {
target: process.env.REMOTE_LSP ?? process.env.REMOTE_EXTRA ?? 'https://app.windmill.dev',