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 <[email protected]>
This commit is contained in:
Patrick BauerandPatrickBauer authored and GitHub committed 2026-03-08 16:30:25 -07:00
1 parent 57aa6bf16c
commit 6271b989bc
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -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 {
+1 -1
View File
@@ -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();
}