Skip to content

Commit fea0bd8

Browse files
author
PatrickBauer
committed
fix(web): use wss:// when page is served over HTTPS
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.
1 parent 59b0527 commit fea0bd8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

apps/web/src/components/Sidebar.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ function getServerHttpOrigin(): string {
225225
? bridgeUrl
226226
: envUrl && envUrl.length > 0
227227
? envUrl
228-
: `ws://${window.location.hostname}:${window.location.port}`;
228+
: `${window.location.protocol === "https:" ? "wss" : "ws"}://${window.location.hostname}:${window.location.port}`;
229229
// Parse to extract just the origin, dropping path/query (e.g. ?token=…)
230230
const httpUrl = wsUrl.replace(/^wss:/, "https:").replace(/^ws:/, "http:");
231231
try {

apps/web/src/wsTransport.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class WsTransport {
4444
? bridgeUrl
4545
: envUrl && envUrl.length > 0
4646
? envUrl
47-
: `ws://${window.location.hostname}:${window.location.port}`);
47+
: `${window.location.protocol === "https:" ? "wss" : "ws"}://${window.location.hostname}:${window.location.port}`);
4848
this.connect();
4949
}
5050

0 commit comments

Comments
 (0)