From e70a02f53aea22202ac246fcbf419c562d974336 Mon Sep 17 00:00:00 2001 From: Roland Osborne Date: Wed, 31 Aug 2022 14:57:17 -0700 Subject: [PATCH] allowing for unfederated http --- net/web/src/context/useAppContext.hook.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/net/web/src/context/useAppContext.hook.js b/net/web/src/context/useAppContext.hook.js index e58b72b3..c8d84931 100644 --- a/net/web/src/context/useAppContext.hook.js +++ b/net/web/src/context/useAppContext.hook.js @@ -123,7 +123,15 @@ export function useAppContext() { cardContext.actions.setToken(token); channelContext.actions.setToken(token); - ws.current = new WebSocket("wss://" + window.location.host + "/status"); + let protocol; + if (window.location.protocol === 'http') { + protocol = 'ws://'; + } + else { + protocol = 'wss://'; + } + + ws.current = new WebSocket(protocol + window.location.host + "/status"); ws.current.onmessage = (ev) => { try { let rev = JSON.parse(ev.data);