authorgravatar for patrick.jean.bauer@gmail.comPatrick Bauer <patrick.jean.bauer@gmail.com> 2026-03-09 00:30:25+01:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-03-08 16:30:25-07:00
log6271b989bc72a255483aa96ccb2868ef4655341d
treea00e0977aca59ebff770a4c74ec04ec1f55ec5cb
parent57aa6bf16cd0dcfbe9037a5ca29ad61bdd2a857e
signature Signed by PGP key B5690EEEBB952194

fix(web): use wss:// when page is served over HTTPS (#391)

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 <patrick@patrickbauer.dev>

2 files changed, 2 insertions(+), 2 deletions(-)

apps/web/src/components/Sidebar.tsx+1-1
...@@ -225,7 +225,7 @@ function getServerHttpOrigin(): string {...@@ -225,7 +225,7 @@ function getServerHttpOrigin(): string {
225 ? bridgeUrl225 ? bridgeUrl
226 : envUrl && envUrl.length > 0226 : envUrl && envUrl.length > 0
227 ? envUrl227 ? envUrl
228 : `ws://${window.location.hostname}:${window.location.port}`;228 : `${window.location.protocol === "https:" ? "wss" : "ws"}://${window.location.hostname}:${window.location.port}`;
229 // Parse to extract just the origin, dropping path/query (e.g. ?token=…)229 // Parse to extract just the origin, dropping path/query (e.g. ?token=…)
230 const httpUrl = wsUrl.replace(/^wss:/, "https:").replace(/^ws:/, "http:");230 const httpUrl = wsUrl.replace(/^wss:/, "https:").replace(/^ws:/, "http:");
231 try {231 try {
apps/web/src/wsTransport.ts+1-1
...@@ -44,7 +44,7 @@ export class WsTransport {...@@ -44,7 +44,7 @@ export class WsTransport {
44 ? bridgeUrl44 ? bridgeUrl
45 : envUrl && envUrl.length > 045 : envUrl && envUrl.length > 0
46 ? envUrl46 ? envUrl
47 : `ws://${window.location.hostname}:${window.location.port}`);47 : `${window.location.protocol === "https:" ? "wss" : "ws"}://${window.location.hostname}:${window.location.port}`);
48 this.connect();48 this.connect();
49 }49 }
5050