make websockets use wss if https

This commit is contained in:
ajuvercr 2020-03-29 19:50:06 +02:00
parent 9af6c9ee26
commit 8f996c03d3

View file

@ -91,7 +91,8 @@
const network = new vis.Network(container, data, options);
var ws = new WebSocket(`ws://${window.location.hostname}:3012`);
var ws = new WebSocket(`${window.location.protocol.startsWith("https") ? 'wss' : 'ws'}://${window.location.hostname}:3012`);
ws.onmessage = function (event) {
handle_event(JSON.parse(event.data));
};