From afa1771c51a29441c8bd714f82f6685e54a150b5 Mon Sep 17 00:00:00 2001 From: "Benjamin Arntzen (aider)" Date: Thu, 27 Jun 2024 09:41:05 +0100 Subject: [PATCH] Implemented secure WebSocket connection based on the current protocol. --- public/app.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/app.js b/public/app.js index bfb5ebd..3a6c4be 100644 --- a/public/app.js +++ b/public/app.js @@ -1,4 +1,5 @@ -const socket = new WebSocket(`ws://${window.location.host}`); +const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:'; +const socket = new WebSocket(`${protocol}//${window.location.host}`); socket.addEventListener('open', () => { console.log('WebSocket connection established');