Use wss in test page when connected with https

This commit is contained in:
Lucas Schumacher 2023-11-01 02:25:12 -04:00
parent 7a7a4b7fce
commit 54efb85dc3

View File

@ -55,7 +55,8 @@ fn index() -> Html<&'static str> {
sendForm.hidden = false;
msgsArea.hidden = false;
msgInput.focus();
ws = new WebSocket("ws://" + window.location.host + "/api/ws");
let protocol = window.location.protocol == "https:" ? "wss://" : "ws://";
ws = new WebSocket(protocol + window.location.host + "/api/ws");
ws.onmessage = function(event) {
msgsArea.value += event.data + "\r\n";
}