From b75a625fbf61103b91e3b404ca1b26a07755b869 Mon Sep 17 00:00:00 2001 From: Tak Hoffman <781889+Takhoffman@users.noreply.github.com> Date: Wed, 4 Mar 2026 23:49:38 -0600 Subject: [PATCH] fix(ui): accept same-origin http and relative gateway URLs for client version --- ui/src/ui/app-gateway.node.test.ts | 20 ++++++++++++++++++++ ui/src/ui/app-gateway.ts | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) 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;