Use relative URL for websocket

Partially merged from branch 'schnusch-http-prefix'
This commit is contained in:
Unrud 2022-01-08 00:15:06 +01:00
commit 130c430d3d
2 changed files with 5 additions and 6 deletions

File diff suppressed because one or more lines are too long

View file

@ -345,10 +345,9 @@ window.addEventListener("load", function() {
text.value = "";
showScene(opening);
ws = new WebSocket(
(location.protocol == "http:" ? "ws:" : "wss:") + "//" + location.hostname +
(location.port ? ":" + location.port : "") + "/ws"
);
let wsURL = new URL("ws", location.href);
wsURL.protocol = wsURL.protocol == "http:" ? "ws:" : "wss:";
ws = new WebSocket(wsURL);
ws.onmessage = function(evt) {
if (authenticated) {