diff --git a/public/main.js b/public/main.js index cbd2f63..2bc9ef3 100644 --- a/public/main.js +++ b/public/main.js @@ -1,5 +1,6 @@ if (!window.mySocket) { - window.mySocket = new WebSocket(`ws://${window.location.host}/user`); + const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; + window.mySocket = new WebSocket(`${wsProtocol}://${window.location.host}/user`); window.mySocket.onopen = function(event) { console.log('WebSocket is open now.');