Compare commits

..

2 Commits

2 changed files with 9 additions and 3 deletions

4
.env
View File

@ -1,8 +1,8 @@
# MongoDB connection for backend
CONNECTION_URI=mongodb://admin:adminpassword@192.168.0.197:27017/ludo?authSource=admin&replicaSet=rs0
CONNECTION_URI=mongodb://admin:adminpassword@192.168.0.197:27018/ludo?authSource=admin&replicaSet=rs0
# Backend port
PORT=8080
PORT=3000
# Environment
NODE_ENV=development

View File

@ -13,7 +13,13 @@ function App() {
const [playerSocket, setPlayerSocket] = useState();
const [redirect, setRedirect] = useState();
useEffect(() => {
const socket = io(`http://${window.location.hostname}:8080`, { withCredentials: true });
let socket;
if(process.env.NODE_ENV !== 'production') {
socket = io(`http://${window.location.hostname}:8080`, { withCredentials: true });
} else {
socket = io(`${window.location.protocol}//${window.location.host}`, { withCredentials: true });
}
socket.on('player:data', data => {
data = JSON.parse(data);
setPlayerData(data);