From 6271b989bc72a255483aa96ccb2868ef4655341d Mon Sep 17 00:00:00 2001 From: Patrick Bauer Date: Mon, 9 Mar 2026 00:30:25 +0100 Subject: [PATCH] fix(web): use wss:// when page is served over HTTPS (#391) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When T3 Code web mode is accessed via HTTPS (e.g. through a reverse proxy or Tailscale Serve), the WebSocket connection must use wss:// instead of ws://. Browsers block mixed content — an insecure ws:// connection initiated from an HTTPS page. Fix: derive the WebSocket protocol from window.location.protocol. Co-authored-by: PatrickBauer --- apps/web/src/components/Sidebar.tsx | 2 +- apps/web/src/wsTransport.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx index e3a3ce02efb49a965e0436203f8d253f8aee4f64..2a96f9e9f37ae46ed2fe6c0c1464b98461cb8efe 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 ef9dddb347c7d6be56822a4efc4433637acdeb8e..faac325a7004cdd5e4eaf11a8c658510bf397052 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(); } -- 2.54.0