I hope you’re doing well.
I’m encountering an issue with deploying my Express backend app that uses Socket.io to interact and broadcast messages from a React app. The React app was created using the “create-react-app” command and then built using “npm run build”. I’m using socket.io-client in the React frontend to communicate with the backend.
Here’s a brief overview of the problem:
Deployment Details:
Express Backend: Uses Socket.io
React Frontend: Built with “create-react-app” and uses socket.io-client
Environment Setup:
I created a .env file and set REACT_APP_API_BASE_URL to the Render domain of the deployed app.
Current Issue:
After successfully deploying the app, everything seems to be working fine. However, when I try to add a new todo, the action executes without error messages, but nothing is inserted into the database.
In the network tab, I see the following issue: each response from the Socket.io server is previewed with the message “You need to enable JavaScript to run this app.” This message usually appears when JavaScript is disabled in the browser.
Please advise on any potential solutions or areas I might have overlooked. Any insights or suggestions would be greatly appreciated!
the todos app built with react displayed after deploying along with network socket responses
I added CORS handling for both the Socket.io server and the Express app, but it did not resolve the issue. I also verified that the CORS configuration was correct. Despite these efforts, the problem persists.
When testing the app on localhost, everything works perfectly as expected. The issue only arises after deployment.
borhane is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.