Use secure websocket connection when loaded over HTTPS

This commit is contained in:
Vojtěch Káně
2021-04-25 19:57:14 +02:00
parent 9f9f5faa9c
commit 7a94ba8fff

View File

@@ -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');