From ab67f068967f7e460f4350384cbe8e47325c0598 Mon Sep 17 00:00:00 2001
From: stuebinm <stuebinm@disroot.org>
Date: Sun, 6 Mar 2022 14:16:00 +0100
Subject: [PATCH] server: don't hardcode the websocket domain/protocol

---
 server/HtmlOrphans.hs | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/server/HtmlOrphans.hs b/server/HtmlOrphans.hs
index b90ea6d..ee30773 100644
--- a/server/HtmlOrphans.hs
+++ b/server/HtmlOrphans.hs
@@ -75,7 +75,8 @@ instance ToHtml JobStatus where
         p_ "you should probably ping an admin about this or sth"
       where
         autoReloadScript = script_
-          "let ws = new WebSocket('ws://localhost:8080' + window.location.pathname + 'realtime');\n\
+          "let proto = window.location.protocol === 'https://' ? 'wss' : 'ws://';\
+          \let ws = new WebSocket(proto + window.location.host + window.location.pathname + 'realtime');\n\
           \ws.onmessage = (event) => {\n\
           \  let resp = JSON.parse(event.data);\n\
           \  if (resp == 'RelintPending') {\n\
-- 
GitLab