Use sandbox control UI origin for dashboard proxy

This commit is contained in:
Codex
2026-04-24 16:24:41 +00:00
parent 8b705e546f
commit bc3b4f661a
4 changed files with 31 additions and 26 deletions
@@ -9,10 +9,11 @@ const serverPath = path.join(root, 'server.mjs')
const proxySource = await readFile(proxyPath, 'utf8')
const serverSource = await readFile(serverPath, 'utf8')
assert.match(proxySource, /const targetOrigin = target\.origin/, 'HTTP proxy must derive an upstream-safe target origin')
assert.match(proxySource, /controlUiOrigin: authority\.openclaw\.controlUiOrigin/, 'HTTP proxy must resolve the OpenClaw control UI origin separately from the transport URL')
assert.match(proxySource, /lowerKey !== 'origin'/, 'HTTP proxy must not forward browser Origin to OpenClaw')
assert.match(proxySource, /headers\.set\('origin', targetOrigin\)/, 'HTTP proxy must rewrite Origin to the loopback/tunnel upstream origin')
assert.match(proxySource, /headers\.set\('referer', `\$\{targetOrigin\}\/`\)/, 'HTTP proxy must rewrite Referer to the upstream origin')
assert.match(serverSource, /headers\.push\(`Origin: \$\{upstreamOrigin\.origin\}`\)/, 'WebSocket tunnel must continue rewriting Origin for gateway upgrades')
assert.match(proxySource, /headers\.set\('origin', controlUiOrigin\)/, 'HTTP proxy must rewrite Origin to the gateway control UI origin')
assert.match(proxySource, /headers\.set\('referer', `\$\{controlUiOrigin\}\/`\)/, 'HTTP proxy must rewrite Referer to the gateway control UI origin')
assert.match(serverSource, /controlUiOrigin: process\.env\.OPENCLAW_SANDBOX_CONTROL_UI_ORIGIN \|\| 'http:\/\/127\.0\.0\.1:18789'/, 'sandbox instances must preserve the gateway internal control UI origin')
assert.match(serverSource, /headers\.push\(`Origin: \$\{controlUiOrigin\}`\)/, 'WebSocket tunnel must rewrite Origin to the gateway control UI origin')
console.log('openclaw-dashboard-origin-rewrite-check: PASS dashboard proxy origin rewrite assertions')