From b9722c4dbb24fee0092c91f74144704964472185 Mon Sep 17 00:00:00 2001 From: Adnaan Date: Sun, 15 Mar 2026 07:28:12 +0100 Subject: [PATCH] fix: use wss:// for WebSocket on HTTPS pages The WebSocket URL was always constructed with ws:// regardless of the page protocol. On HTTPS pages, browsers block mixed-content WebSocket connections with a SecurityError, making LiveTemplate non-functional behind any TLS-terminating reverse proxy (Fly.io, Cloudflare, AWS ALB). Now detects window.location.protocol and uses wss: for https: pages. Co-Authored-By: Claude Opus 4.6 --- transport/websocket.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/transport/websocket.ts b/transport/websocket.ts index aee494a..656a088 100644 --- a/transport/websocket.ts +++ b/transport/websocket.ts @@ -203,7 +203,8 @@ export class WebSocketManager { if (baseUrl) { return baseUrl; } - return `ws://${window.location.host}${liveUrl}`; + const wsScheme = window.location.protocol === "https:" ? "wss:" : "ws:"; + return `${wsScheme}//${window.location.host}${liveUrl}`; } private getLiveUrl(): string {