From 40c6603226ed8de568547e6c627ba2ae89d7c5df Mon Sep 17 00:00:00 2001 From: Ethan Apodaca Date: Wed, 21 Apr 2021 17:42:53 -0700 Subject: [PATCH] Use correct websocket protocol Based on window location the correct websocket protocol can be used. --- client/scripts.html | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/scripts.html b/client/scripts.html index ca4b9bb..755adab 100644 --- a/client/scripts.html +++ b/client/scripts.html @@ -117,8 +117,9 @@ } function getWebsocketConnection(onOpen,onMessage){ + const wsProto = window.location.protocol.startsWith('https') ? 'wss://' : 'ws://'; // Create WebSocket connection. - const socket = new WebSocket('ws://'+window.location.host+'/ws'); + const socket = new WebSocket(wsProto+window.location.host+'/ws'); socket.addEventListener('open', onOpen);