diff options
-rw-r--r-- | public/main.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/public/main.js b/public/main.js index da4083e..b3c7986 100644 --- a/public/main.js +++ b/public/main.js @@ -1,7 +1,8 @@ document.addEventListener("DOMContentLoaded", async () => { "use strict" const $ = s => document.querySelector(s); -const sock = new WebSocket(`ws://${location.host}/ws`); +const secure = location.protocol === "https:"; +const sock = new WebSocket(`ws${secure?"s":""}://${location.host}/ws`); sock.onmessage = e => console.log("sock", e); sock.onopen = () => sock.send("yay"); |