mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-19 22:10:51 +00:00
Normalize basePath before building default WebSocket URL
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 <noreply@anthropic.com>
This commit is contained in:
committed by
Radek Sienkiewicz
parent
3ed11f9651
commit
413d41a79a
@@ -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}`;
|
||||
})();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user