Support wss if made from https

This commit is contained in:
Nick Mowen 2022-10-21 09:15:31 -06:00
parent 0e000e7ee6
commit 94e74689d3

View File

@ -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(() => {