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 = ""; text.value = "";
showScene(opening); showScene(opening);
ws = new WebSocket( let wsURL = new URL("ws", location.href);
(location.protocol == "http:" ? "ws:" : "wss:") + "//" + location.hostname + wsURL.protocol = wsURL.protocol == "http:" ? "ws:" : "wss:";
(location.port ? ":" + location.port : "") + "/ws" ws = new WebSocket(wsURL);
);
ws.onmessage = function(evt) { ws.onmessage = function(evt) {
if (authenticated) { if (authenticated) {