diff --git a/html/rfid.js b/html/rfid.js
index ae9cd68..830d3b8 100644
--- a/html/rfid.js
+++ b/html/rfid.js
@@ -59,7 +59,8 @@ function initWebSocket() {
}
try {
- socket = new WebSocket('ws://' + window.location.host + '/ws');
+ const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
+ socket = new WebSocket(protocol + '//' + window.location.host + '/ws');
socket.onopen = function() {
isConnected = true;
diff --git a/html/upgrade.html b/html/upgrade.html
index 5bbcedf..57ee63b 100644
--- a/html/upgrade.html
+++ b/html/upgrade.html
@@ -102,7 +102,8 @@
2) Webpage Update
let wsReconnectTimer = null;
function connectWebSocket() {
- ws = new WebSocket('ws://' + window.location.host + '/ws');
+ const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
+ ws = new WebSocket(protocol + '//' + window.location.host + '/ws');
ws.onmessage = function(event) {
try {
diff --git a/html/waage.html b/html/waage.html
index 40ffa5c..40a2468 100644
--- a/html/waage.html
+++ b/html/waage.html
@@ -86,7 +86,8 @@ Calibration done
const statusMessage = document.getElementById('statusMessage');
function connectWebSocket() {
- ws = new WebSocket(`ws://${window.location.hostname}/ws`);
+ const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
+ ws = new WebSocket(`${protocol}//${window.location.host}/ws`);
ws.onopen = () => {
console.log('WebSocket verbunden');