From b9c4f4a24b83bdb03742cbd0e68cdc46d0a2ed13 Mon Sep 17 00:00:00 2001 From: Siyuan Miao Date: Tue, 8 Apr 2025 18:17:20 +0200 Subject: [PATCH] fix: use wss when the page is served over https --- ui/src/routes/devices.$id.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ui/src/routes/devices.$id.tsx b/ui/src/routes/devices.$id.tsx index 1a86a37..df465b6 100644 --- a/ui/src/routes/devices.$id.tsx +++ b/ui/src/routes/devices.$id.tsx @@ -232,10 +232,12 @@ export default function KvmIdRoute() { const isSettingRemoteAnswerPending = useRef(false); const makingOffer = useRef(false); + const wsProtocol = window.location.protocol === "https:" ? "wss:" : "ws:"; + console.log("isondevice", isOnDevice); const { sendMessage } = useWebSocket( isOnDevice - ? `ws://${window.location.host}/webrtc/signaling` + ? `${wsProtocol}//${window.location.host}/webrtc/signaling` : `${CLOUD_API.replace("http", "ws")}/webrtc/signaling?id=${params.id}`, { heartbeat: true,