Skip to content

Commit 32fa20b

Browse files
fix[frontend](proxy): removed origin header on localhost proxy (#2479)
1 parent ec9afae commit 32fa20b

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎frontend/vite.config.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ const API_TARGET = FEDERATION ? FS_URL : BACKEND_URL
2323
// request looks same-origin. Dev-only convenience for admins of the target
2424
// instance; do not rely on this to bypass origin checks you don't control.
2525
type ConfigureProxy = NonNullable<import('vite').ProxyOptions['configure']>
26+
console.log(BACKEND_URL)
2627

2728
const spoofOriginHeaders: ConfigureProxy = (proxy) => {
2829
proxy.on('proxyReq', (proxyReq, req) => {
29-
if (req.headers.origin?.startsWith('http://localhost')) return
30-
proxyReq.setHeader('Origin', API_TARGET)
3130
proxyReq.setHeader('Referer', API_TARGET + '/')
31+
if (!req.headers.origin || req.headers.origin?.startsWith('http://localhost')) return
32+
proxyReq.setHeader('Origin', API_TARGET)
3233
})
3334
}
3435

0 commit comments

Comments
 (0)