js: app: use wss:// when connecting via https
Some browsers require a websocket connection to an encrypted server
be made using the "wss://" uri.
This patch checks to see if the protocol is https, and sets a default
protocol of "wss://" if this is the case.
@@ -81,7 +81,7 @@ window.GoAccess = window.GoAccess || {
setWebSocket: function (wsConn) {
var host = null, host = wsConn.url ? wsConn.url : window.location.hostname ? window.location.hostname : "localhost";
var str = /^(wss?:\/\/)?[^\/]+:[0-9]{1,5}\//.test(host + "/") ? host : String(host + ':' + wsConn.port);
- str = !/^wss?:\/\//i.test(str) ? 'ws://' + str : str;
+ str = !/^wss?:\/\//i.test(str) ? (window.location.protocol === "https:" ? 'wss://' : 'ws://') + str : str;
var socket = new WebSocket(str);
socket.onopen = function (event) {
