From 94516ef341807fccb4c999aef746b8968928ea98 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sat, 8 Jun 2019 23:36:16 +0200 Subject: [PATCH] implement https detection (thanks Denys Vitali) --- htdocs/openwebrx.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/openwebrx.js b/htdocs/openwebrx.js index 3808f92..40f95c2 100644 --- a/htdocs/openwebrx.js +++ b/htdocs/openwebrx.js @@ -1812,7 +1812,12 @@ String.prototype.startswith=function(str){ return this.indexOf(str) == 0; }; //h function open_websocket() { - ws_url="ws://"+(window.location.origin.split("://")[1])+"/ws/"; //guess automatically -> now default behaviour + var protocol = 'ws'; + if (window.location.toString().startsWith('https://')) { + protocol = 'wss'; + } + + ws_url = protocol + "://" + (window.location.origin.split("://")[1]) + "/ws/"; //guess automatically -> now default behaviour if (!("WebSocket" in window)) divlog("Your browser does not support WebSocket, which is required for WebRX to run. Please upgrade to a HTML5 compatible browser."); ws = new WebSocket(ws_url);