Fix connecting to websocket with SSL

Request a secure web socket (wss://) when connecting to the site with
https.  Fixes #61.
This commit is contained in:
Zorchenhimer 2019-04-13 13:47:38 -04:00
parent ad2579d59a
commit 332dfdc9cf
2 changed files with 6 additions and 1 deletions

View File

@ -68,6 +68,7 @@ func wsWasmFile(w http.ResponseWriter, r *http.Request) {
if settings.NoCache {
w.Header().Set("Cache-Control", "no-cache, must-revalidate")
}
common.LogDebugln("[static] serving wasm file")
http.ServeFile(w, r, "./static/main.wasm")
}

View File

@ -59,7 +59,11 @@ function getWsUri() {
if (port != "") {
port = ":" + port;
}
return "ws://" + window.location.hostname + port + "/ws";
proto = "ws://"
if (location.protocol == "https:") {
proto = "wss://"
}
return proto + window.location.hostname + port + "/ws";
}
let maxMessageCount = 0