I have developed a basic chat application using sockets, MongoDB, and Express. Everything functions smoothly when the application is running on my local machine (localhost:4000). I can establish connections to MongoDB, send messages, and receive responses without any issues. Problem: However, there seems to be an issue when accessing the app through a mobile browser using the IP address of my PC (e.g., 192.168.1.108:4000). While I am able to view the index.html page, I encounter difficulties in sending and receiving messages as well as loading previous messages stored in MongoDB.
//server.js
var express = require('express');
var app = express();
var server = require('http').createServer(app);
connections = [];
app.use(express.static(__dirname + '/public'));
server.listen(process.env.PORT || 4000);
console.log('Server Running');
//remaining code omitted for brevity