diff --git a/frontend/.env.production b/frontend/.env.production index 94a047ee..42932a18 100644 --- a/frontend/.env.production +++ b/frontend/.env.production @@ -1,3 +1,9 @@ +<<<<<<< HEAD NEXT_PUBLIC_HOSTNAME=141.136.42.178 PORT=80 NEXT_PUBLIC_HOST=http://$NEXT_PUBLIC_HOSTNAME:$PORT +======= +NEXT_PUBLIC_HOSTNAME=192.168.1.18 +NEXT_PUBLIC_PORT=80 +NEXT_PUBLIC_HOST=http://$NEXT_PUBLIC_HOSTNAME:$NEXT_PUBLIC_PORT +>>>>>>> 14ab2403983411dea6475cad781ddef9a1c89b7c diff --git a/frontend/components/room/Join.jsx b/frontend/components/room/Join.jsx index aa083cca..415261c9 100644 --- a/frontend/components/room/Join.jsx +++ b/frontend/components/room/Join.jsx @@ -37,7 +37,7 @@ export default function Join() { isBrowser && isEmpty(authData) && sessionStorage.getItem("clientId") ) .then((res) => { - connect(`ws://192.168.1.18:8000/ws/room/${res.id_code}`); + connect(`/ws/room/${res.id_code}`); if (res.is_auth) { router.push({ pathname: "/room/" + res.id_code }, undefined, { shallow: true, @@ -109,7 +109,7 @@ export default function Join() { checkRoom(infos.pin, (isBrowser && isEmpty(authData)) && sessionStorage.getItem('clientId')) .then((res) => { setErrorRoom({ message: "" }); - connect(`ws://192.168.1.18:8000/ws/room/${res.id_code}`); + connect(`/ws/room/${res.id_code}`); if (res.is_auth) { router.push( { pathname: "/room/" + res.id_code }, diff --git a/frontend/components/room/RoomPage.jsx b/frontend/components/room/RoomPage.jsx index 4ae914e7..70f06fbb 100644 --- a/frontend/components/room/RoomPage.jsx +++ b/frontend/components/room/RoomPage.jsx @@ -30,7 +30,7 @@ export default function RoomPage({ id_code, user }) { useEffect(() => { if (isConnected == false && isBrowser) { - connect("ws://192.168.1.18:8000/ws/room/" + id_code); + connect("/ws/room/" + id_code); send({ data: { type: "reconnect", diff --git a/frontend/components/room/RoomView.jsx b/frontend/components/room/RoomView.jsx index da7e4251..0a404b0c 100644 --- a/frontend/components/room/RoomView.jsx +++ b/frontend/components/room/RoomView.jsx @@ -315,7 +315,7 @@ export default function RoomView({ user, id_code }) { onClick={() => { setDataRoom(); if (!isConnected) { - connect("ws://192.168.1.18:8000/ws/room/" + id_code); + connect("/ws/room/" + id_code); } }} className={styles.refresh} diff --git a/frontend/components/room/WaitingRoom.jsx b/frontend/components/room/WaitingRoom.jsx index 34d909ff..591a2a29 100644 --- a/frontend/components/room/WaitingRoom.jsx +++ b/frontend/components/room/WaitingRoom.jsx @@ -25,7 +25,7 @@ export default function WaitingRoom() { checkRoom(router.query.mode[1]) .then(() => { console.log('CONNECT HERE TO') - connect(`ws://192.168.1.18:8000/ws/room/${router.query.mode[1]}`); + connect(`ws/room/${router.query.mode[1]}`); send({ data: { type: "login", diff --git a/frontend/context/websocket.context.js b/frontend/context/websocket.context.js index a025a0fe..b3c2e64c 100644 --- a/frontend/context/websocket.context.js +++ b/frontend/context/websocket.context.js @@ -14,7 +14,13 @@ export const WebsocketProvider = ({ children }) => { const router = useRouter(); const connect = (url) => { if (isBrowser) { - ws.current = new ReconnectingWebSocket(url); + + var url = url.startsWith('/')? url: '/' + url + + ws.current = new ReconnectingWebSocket( + `ws://${process.env.NEXT_PUBLIC_HOST}:${process.env.NEXT_PUBLIC_PORT}${url}` + ); + ws.current.onopen = () => { setConnected(true); };