diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index e3a3ce02ef..2a96f9e9f3 100644 --- a/apps/web/src/components/Sidebar.tsx +++ b/apps/web/src/components/Sidebar.tsx @@ -225,7 +225,7 @@ function getServerHttpOrigin(): string { ? bridgeUrl : envUrl && envUrl.length > 0 ? envUrl - : `ws://${window.location.hostname}:${window.location.port}`; + : `${window.location.protocol === "https:" ? "wss" : "ws"}://${window.location.hostname}:${window.location.port}`; // Parse to extract just the origin, dropping path/query (e.g. ?token=…) const httpUrl = wsUrl.replace(/^wss:/, "https:").replace(/^ws:/, "http:"); try { diff --git a/apps/web/src/wsTransport.ts b/apps/web/src/wsTransport.ts index ef9dddb347..faac325a70 100644 --- a/apps/web/src/wsTransport.ts +++ b/apps/web/src/wsTransport.ts @@ -44,7 +44,7 @@ export class WsTransport { ? bridgeUrl : envUrl && envUrl.length > 0 ? envUrl - : `ws://${window.location.hostname}:${window.location.port}`); + : `${window.location.protocol === "https:" ? "wss" : "ws"}://${window.location.hostname}:${window.location.port}`); this.connect(); }