From fea0bd8ddc46ecff9b8a2d53064d00bad2c536b7 Mon Sep 17 00:00:00 2001 From: PatrickBauer Date: Sat, 7 Mar 2026 16:48:04 +0100 Subject: [PATCH] fix(web): use wss:// when page is served over HTTPS 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. --- 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 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(); }