diff --git a/ui/src/ui/app-gateway.node.test.ts b/ui/src/ui/app-gateway.node.test.ts index c386e14d093..6915a30f999 100644 --- a/ui/src/ui/app-gateway.node.test.ts +++ b/ui/src/ui/app-gateway.node.test.ts @@ -243,6 +243,26 @@ describe("resolveControlUiClientVersion", () => { ).toBe("2026.3.3"); }); + it("returns serverVersion for same-origin relative targets", () => { + expect( + resolveControlUiClientVersion({ + gatewayUrl: "/ws", + serverVersion: "2026.3.3", + pageUrl: "https://control.example.com/openclaw/", + }), + ).toBe("2026.3.3"); + }); + + it("returns serverVersion for same-origin http targets", () => { + expect( + resolveControlUiClientVersion({ + gatewayUrl: "https://control.example.com/ws", + serverVersion: "2026.3.3", + pageUrl: "https://control.example.com/openclaw/", + }), + ).toBe("2026.3.3"); + }); + it("omits serverVersion for cross-origin targets", () => { expect( resolveControlUiClientVersion({ diff --git a/ui/src/ui/app-gateway.ts b/ui/src/ui/app-gateway.ts index 805fcb31570..15b885be26a 100644 --- a/ui/src/ui/app-gateway.ts +++ b/ui/src/ui/app-gateway.ts @@ -102,8 +102,8 @@ export function resolveControlUiClientVersion(params: { try { const page = new URL(pageUrl); const gateway = new URL(params.gatewayUrl, page); - const expectedWsProtocol = page.protocol === "https:" ? "wss:" : "ws:"; - if (gateway.protocol !== expectedWsProtocol || gateway.host !== page.host) { + const allowedProtocols = new Set(["ws:", "wss:", "http:", "https:"]); + if (!allowedProtocols.has(gateway.protocol) || gateway.host !== page.host) { return undefined; } return serverVersion;