fix: use wss when the page is served over https

This commit is contained in:
Siyuan Miao 2025-04-08 18:17:20 +02:00
parent a9a8df5d9c
commit b9c4f4a24b
1 changed files with 3 additions and 1 deletions

View File

@ -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,