diff --git a/src/frontend/package.json b/src/frontend/package.json index 2086aa817..69eb7b47f 100644 --- a/src/frontend/package.json +++ b/src/frontend/package.json @@ -39,7 +39,7 @@ "web-vitals": "^2.1.4" }, "scripts": { - "start": "react-scripts start", + "start": "NODE_ENV=development react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" @@ -62,5 +62,5 @@ "last 1 safari version" ] }, - "proxy": "http://127.0.0.1:5003" + "proxy": "http://backend:7860" } \ No newline at end of file diff --git a/src/frontend/src/modals/chatModal/index.tsx b/src/frontend/src/modals/chatModal/index.tsx index c3eefaf6c..68b8df998 100644 --- a/src/frontend/src/modals/chatModal/index.tsx +++ b/src/frontend/src/modals/chatModal/index.tsx @@ -55,7 +55,14 @@ export default function ChatModal({ }; function connectWS() { - const newWs = new WebSocket(`ws://127.0.0.1:7860/chat/${flow.id}`); + // Check if the app is running with npm start or npm run build + // if npm start, use localhost, otherwise use the windows.location.host + const urlWs = + process.env.NODE_ENV === "development" + ? `ws://localhost:7860/chat/${flow.id}` + : `wss://${window.location.host}/chat/${flow.id}`; + + const newWs = new WebSocket(urlWs); newWs.onopen = () => { console.log("WebSocket connection established!"); };