From 94e74689d3a7a99a9bf6681bbb88000b58f2365a Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Fri, 21 Oct 2022 09:15:31 -0600 Subject: [PATCH] Support wss if made from https --- web/src/components/WebRtcPlayer.jsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/src/components/WebRtcPlayer.jsx b/web/src/components/WebRtcPlayer.jsx index 2d523a14e..5fa47842a 100644 --- a/web/src/components/WebRtcPlayer.jsx +++ b/web/src/components/WebRtcPlayer.jsx @@ -3,7 +3,12 @@ import { h } from 'preact'; let ws; function initStream(camera) { - ws = new WebSocket(`ws://${window.location.host}/go2rtc/api/ws?src=${camera}`); + if (location.protocol == 'https') { + ws = new WebSocket(`wss://${window.location.host}/go2rtc/api/ws?src=${camera}`); + } else { + ws = new WebSocket(`ws://${window.location.host}/go2rtc/api/ws?src=${camera}`); + } + ws.onopen = () => { pc.createOffer().then(offer => { pc.setLocalDescription(offer).then(() => {