node.jsdeploymentsocket.ioreal-time

Socket.io not working after deployment on render.com


https://github.com/santukumar01/Mern-chat-app

I have deployed a MERN stack chat application on Render.com, and while basic functionalities like login and registration are working fine, the real-time chat functionality is failing. The application works as expected locally, but not after deployment.

Below type of error I get.

Failed to load resource: net::ERR_CONNECTION_REFUSED index-Q4Sg5fsh.js:428

GET http://localhost:3000/socket.io/?EIO=4&transport=polling&t=OxY6Y47 net::ERR_CONNECTION_REFUSED

Any suggestions are highly appreciated. Help me to achieve real-time functionality.

I expect to send and receive all chats in real. If you can help me with notification and typing functionality that would be great.

but every time I refresh the page then I am able to see the new chat msg

Deployed link: https://mern-chat-app-q2n6.onrender.com


Solution

  • I can't comment so writing it here

    You might want to update your cors settings for deployment

        cors: {
            // at line 47
            origin: "http://localhost:5173"  // frontend server
        }