diff --git a/package.json b/package.json index a80dce3..7a89855 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ }, "scripts": { "start": "node server.js", + "start:prod": "NODE_ENV=production node server.js", "dev": "node server.js", "docker:build": "docker build -t encrypted-todo .", "docker:run": "docker run -p 3000:3000 encrypted-todo", diff --git a/public/index.html b/public/index.html index 026a79f..dbe966a 100644 --- a/public/index.html +++ b/public/index.html @@ -75,8 +75,10 @@ function connectWebSocket() { if (!currentUser) return; + const protocol = + window.location.protocol === "https:" ? "wss:" : "ws:"; ws = new WebSocket( - `ws://${window.location.host}?userId=${currentUser}`, + `${protocol}//${window.location.host}?userId=${currentUser}`, ); ws.onmessage = (event) => { const msg = JSON.parse(event.data);