From 413d41a79aefc378e2883695daa86fa123509440 Mon Sep 17 00:00:00 2001 From: Ben Gitter Date: Sun, 1 Mar 2026 02:28:00 +0000 Subject: [PATCH] Normalize basePath before building default WebSocket URL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When window.__OPENCLAW_CONTROL_UI_BASE_PATH__ is set, normalize it via normalizeBasePath() before concatenation — matching what inferBasePath() in app-settings.ts already does. Without this, values like "openclaw" (no leading slash) or "/openclaw/" (trailing slash) produce malformed WebSocket URLs on first load. Co-Authored-By: Claude Opus 4.6 --- ui/src/ui/storage.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ui/src/ui/storage.ts b/ui/src/ui/storage.ts index e8d281755bb..757dc9eab7f 100644 --- a/ui/src/ui/storage.ts +++ b/ui/src/ui/storage.ts @@ -1,7 +1,7 @@ const KEY = "openclaw.control.settings.v1"; import { isSupportedLocale } from "../i18n/index.ts"; -import { inferBasePathFromPathname } from "./navigation.ts"; +import { inferBasePathFromPathname, normalizeBasePath } from "./navigation.ts"; import type { ThemeMode } from "./theme.ts"; export type UiSettings = { @@ -21,9 +21,13 @@ export type UiSettings = { export function loadSettings(): UiSettings { const defaultUrl = (() => { const proto = location.protocol === "https:" ? "wss" : "ws"; - const basePath = - (typeof window !== "undefined" && window.__OPENCLAW_CONTROL_UI_BASE_PATH__) || - inferBasePathFromPathname(location.pathname); + const configured = + typeof window !== "undefined" && + typeof window.__OPENCLAW_CONTROL_UI_BASE_PATH__ === "string" && + window.__OPENCLAW_CONTROL_UI_BASE_PATH__.trim(); + const basePath = configured + ? normalizeBasePath(configured) + : inferBasePathFromPathname(location.pathname); return `${proto}://${location.host}${basePath}`; })();