Stabilize OpenClaw dashboard websocket sidecar

This commit is contained in:
Codex
2026-04-24 15:28:47 +00:00
parent 90112c3ff9
commit a5eca0d188
4 changed files with 150 additions and 48 deletions
+5 -1
View File
@@ -19,8 +19,12 @@ function buildBrowserGatewayUrl(request: Request, requestUrl: URL, proxiedUrl: s
const forwardedHost = firstHeaderValue(request.headers.get('x-forwarded-host'))
const host = forwardedHost || request.headers.get('host') || requestUrl.host
const protocol = (forwardedProtocol || requestUrl.protocol.replace(/:$/, '')) === 'https' ? 'wss:' : 'ws:'
const wsProxyPort = process.env.OPENCLAW_DASHBOARD_WS_PROXY_PORT?.trim() || '3001'
const gatewayHost = wsProxyPort
? new URL(`${requestUrl.protocol}//${host}`).hostname + `:${wsProxyPort}`
: host
return `${protocol}//${host}${proxiedUrl}`
return `${protocol}//${gatewayHost}${proxiedUrl}`
}
function buildLaunchUrl(request: Request, requestUrl: URL, proxiedUrl: string, bootstrapUrl: string | null) {