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}`; })();