diff --git a/static/js/main.js b/static/js/main.js index 51a80ef..1f65f10 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -1,6 +1,8 @@ (($) => { + const isSecure = location.protocol === "https:"; + const port = location.port ? `:${location.port}` : ""; var ws = new WebSocket( - `ws://${location.protocol + "//" + location.host}${location.port ? ":" + location.port : ""}/ws`, + `ws${isSecure ? "s" : ""}://${location.host}${port}/ws`, ); const input = $("#message"); const messages = $("#messages");