From 078ee42f5120efcb1584294c3bd19e84296b62ae Mon Sep 17 00:00:00 2001 From: bskjon Date: Thu, 27 Feb 2025 18:49:02 +0100 Subject: [PATCH] Url fix --- apps/ui/web/src/index.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/ui/web/src/index.tsx b/apps/ui/web/src/index.tsx index 4b911916..839f11f2 100644 --- a/apps/ui/web/src/index.tsx +++ b/apps/ui/web/src/index.tsx @@ -11,13 +11,20 @@ const root = ReactDOM.createRoot( document.getElementById('root') as HTMLElement ); -const protocol = window.location.protocol; -const host = window.location.host; -const wsUrl = "http://localhost:8080/ws" //`${protocol}//${host}/ws`; + +const wsUrl = () => { + const protocol = window.location.protocol; + const host = window.location.host; + if (window.location.href.startsWith("http://localhost:3000")) { + return "http://localhost:8080/ws"; + } else { + return `${protocol}//${host}/ws`; + } +} root.render( - { if (str === "Opening Web Socket...") { }