feat(frontend): add support for environment variable NODE_ENV in start script
feat(frontend): change proxy to backend container name feat(chatModal): add support for environment variable NODE_ENV in WebSocket connection
This commit is contained in:
parent
cdc6d2994a
commit
1e8f342037
2 changed files with 10 additions and 3 deletions
|
|
@ -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"
|
||||
}
|
||||
|
|
@ -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!");
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue