mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-12-03 16:10:37 +00:00
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:
co-authored by
Claude Opus 5.5
parent
047e1530c0
commit
0dd0a78384
+17
-2
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user