Stabilize OpenClaw dashboard websocket bootstrap

This commit is contained in:
Codex
2026-04-24 14:12:46 +00:00
parent 75c356ebdf
commit 7b23d61a4d
2 changed files with 33 additions and 6 deletions
+7 -1
View File
@@ -134,8 +134,14 @@ function proxiedAssetPath(value: string, proxyPrefix: string) {
return `${proxyPrefix}/${normalized}`
}
function injectOpenClawBootstrap(body: string, proxyPrefix: string) {
const bootstrap = `<script>window.__OPENCLAW_CONTROL_UI_BASE_PATH__=${JSON.stringify(proxyPrefix)};</script>`
return body.replace(/<head(\s[^>]*)?>/i, (match) => `${match}${bootstrap}`)
}
function rewriteHtml(body: string, proxyPrefix: string) {
return body.replace(
return injectOpenClawBootstrap(body, proxyPrefix).replace(
/(<(?:script|img|link)\b[^>]*\s(?:src|href)=)(["'])([^"']+)(["'])/gi,
(_match, prefix: string, quote: string, value: string, suffix: string) =>
`${prefix}${quote}${proxiedAssetPath(value, proxyPrefix)}${suffix}`