From 7a94ba8fffb14416c73624842b881f4870680f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vojt=C4=9Bch=20K=C3=A1n=C4=9B?= Date: Sun, 25 Apr 2021 19:57:14 +0200 Subject: [PATCH] Use secure websocket connection when loaded over HTTPS --- ui/html/game.page.tmpl.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/html/game.page.tmpl.html b/ui/html/game.page.tmpl.html index e527265..800fad0 100644 --- a/ui/html/game.page.tmpl.html +++ b/ui/html/game.page.tmpl.html @@ -41,7 +41,7 @@ const playerId = namesSection.dataset.myId; - const socket = new WebSocket('ws://' + window.location.host + '/ws/' + encodeURIComponent(playerId)); + const socket = new WebSocket((document.location.protocol.toLowerCase() === 'https:' ? 'wss' : 'ws') + '://' + window.location.host + '/ws/' + encodeURIComponent(playerId)); document.addEventListener("DOMContentLoaded", () => { const next = document.querySelector('#controls .next');