diff --git a/public/script.js b/public/script.js index d0ed3e0..d70c765 100644 --- a/public/script.js +++ b/public/script.js @@ -21,7 +21,11 @@ let config = {}; let ws = null; function tryConnect() { - let c = new WebSocket("ws://" + window.location.host); + let wsProtocol = 'ws://'; + if (window.location.protocol === 'https:') { + wsProtocol = 'wss://'; + } + let c = new WebSocket(wsProtocol + window.location.host); c.addEventListener('message', function (event) { handleMessage(JSON.parse(event.data)); });