From b01309c3bfc2008b157b7585ab37d9966b8177ce Mon Sep 17 00:00:00 2001 From: PLCHome Date: Mon, 7 Mar 2022 18:26:53 +0100 Subject: [PATCH] Mixed content exception in web browser in websocket communication on peek behind an https backproxy. (#2571) "ws://" must be the change to the "wss://" for encryption --- wled00/data/index.js | 2 +- wled00/data/liveviewws.htm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wled00/data/index.js b/wled00/data/index.js index f8359d0e2..c3ef0c5da 100644 --- a/wled00/data/index.js +++ b/wled00/data/index.js @@ -1000,7 +1000,7 @@ function reconnectWS() { function makeWS() { if (ws) return; - ws = new WebSocket('ws://'+(loc?locip:window.location.hostname)+'/ws'); + ws = new WebSocket((window.location.protocol == 'https:'?'wss':'ws')+'://'+(loc?locip:window.location.hostname)+'/ws'); ws.binaryType = "arraybuffer"; ws.onmessage = function(event) { if (event.data instanceof ArrayBuffer) return; //liveview packet diff --git a/wled00/data/liveviewws.htm b/wled00/data/liveviewws.htm index 9ad2a667d..9234d317c 100644 --- a/wled00/data/liveviewws.htm +++ b/wled00/data/liveviewws.htm @@ -51,7 +51,7 @@ ws.send("{'lv':true}"); } else { console.info("Peek WS opening"); - ws = new WebSocket("ws://"+document.location.host+"/ws"); + ws = new WebSocket((window.location.protocol == "https:"?"wss":"ws")+"://"+document.location.host+"/ws"); ws.onopen = function () { console.info("Peek WS open"); ws.send("{'lv':true}");