From f6b98599e0f64160eae02bb1f0c7382b201f3c5f Mon Sep 17 00:00:00 2001 From: Ted Kesgar Date: Wed, 12 Aug 2026 08:22:55 +0700 Subject: [PATCH 1/3] Extract websocket host logic into getWebsocketHost function Refactor websocket host determination logic to a separate function. Signed-off-by: Ted Kesgar --- apps/frontend/src/state/epics/wsEpics.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/frontend/src/state/epics/wsEpics.ts b/apps/frontend/src/state/epics/wsEpics.ts index b6e90137..d6f8aa0c 100644 --- a/apps/frontend/src/state/epics/wsEpics.ts +++ b/apps/frontend/src/state/epics/wsEpics.ts @@ -26,14 +26,19 @@ import { let socket$: WebSocketSubject | null = null -const isElectron = window.location.protocol === "file:" -const isHttps = window.location.protocol === "https:" +const getWebsocketHost = () => { + const isElectron = window.location.protocol === "file:" + if (isElectron) { + return "ws://localhost:8080" + } + + return (window.location.origin + window.location.pathname) + .replace(/^http/, 'ws') +} const url = import.meta.env.VITE_VALKEY_ADMIN_WS_URL || - (isElectron - ? "ws://localhost:8080" - : `${isHttps ? "wss" : "ws"}://${window.location.host}`) + getWebsocketHost() const connect = (store: Store) => action$.pipe( From 4b08ff3d9452f4dd5de02ffa5e7444e830e38488 Mon Sep 17 00:00:00 2001 From: Ted Kesgar Date: Wed, 12 Aug 2026 08:41:39 +0700 Subject: [PATCH 2/3] Rename function getWebsocketHost to getWebsocketURL Signed-off-by: Ted Kesgar --- apps/frontend/src/state/epics/wsEpics.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/frontend/src/state/epics/wsEpics.ts b/apps/frontend/src/state/epics/wsEpics.ts index d6f8aa0c..92ca7b5b 100644 --- a/apps/frontend/src/state/epics/wsEpics.ts +++ b/apps/frontend/src/state/epics/wsEpics.ts @@ -26,7 +26,7 @@ import { let socket$: WebSocketSubject | null = null -const getWebsocketHost = () => { +const getWebsocketURL = () => { const isElectron = window.location.protocol === "file:" if (isElectron) { return "ws://localhost:8080" @@ -38,7 +38,7 @@ const getWebsocketHost = () => { const url = import.meta.env.VITE_VALKEY_ADMIN_WS_URL || - getWebsocketHost() + getWebsocketURL() const connect = (store: Store) => action$.pipe( From 553b13bd5b2ddc8dd434c3fe94ab03baaaff81d9 Mon Sep 17 00:00:00 2001 From: Ted Kesgar Date: Thu, 13 Aug 2026 13:02:24 +0700 Subject: [PATCH 3/3] Update apps/frontend/src/state/epics/wsEpics.ts Co-authored-by: Ravjot Brar <83892020+ravjotbrar@users.noreply.github.com> Signed-off-by: Ted Kesgar --- apps/frontend/src/state/epics/wsEpics.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/frontend/src/state/epics/wsEpics.ts b/apps/frontend/src/state/epics/wsEpics.ts index 92ca7b5b..faef520b 100644 --- a/apps/frontend/src/state/epics/wsEpics.ts +++ b/apps/frontend/src/state/epics/wsEpics.ts @@ -27,13 +27,13 @@ import { let socket$: WebSocketSubject | null = null const getWebsocketURL = () => { - const isElectron = window.location.protocol === "file:" - if (isElectron) { + // If it's an Electron deployment + if (window.location.protocol === "file:") { return "ws://localhost:8080" } - return (window.location.origin + window.location.pathname) - .replace(/^http/, 'ws') + const protocol = window.location.protocol === "https:" ? "wss" : "ws" + return `${protocol}://${window.location.host}${window.location.pathname}` } const url =