Skip to content

Commit 82431dd

Browse files
committed
hardcoded url removed
1 parent 6db8873 commit 82431dd

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/contexts/socket.context.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,14 @@ function useSocketDispatch() {
9191
}
9292

9393
function connect(dispatch: Dispatch) {
94-
const socket = socketIOClient("http://127.0.0.1:4201");
95-
dispatch({ type: "connect", payload: socket });
96-
console.log("Socket connected");
94+
const apiUrl = process.env.REACT_APP_API_URL;
95+
if (apiUrl) {
96+
const socket = socketIOClient(apiUrl);
97+
dispatch({ type: "connect", payload: socket });
98+
console.log("Socket connected");
99+
} else {
100+
console.log("API url is not provided: " + apiUrl);
101+
}
97102
}
98103

99104
export { SocketProvider, useSocketState, useSocketDispatch, connect };

0 commit comments

Comments
 (0)