diff --git a/src/main.rs b/src/main.rs index dfcf743..ffc55a6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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"; }