I am a beginner trying to build a web app using React and MongoDB, and I am having some trouble connecting to my database. It works perfectly on my computer, both on localhost and GitHub Pages. However, when I try to access the GitHub Page from a different device, I can no longer fetch data from the database or add/edit stuff. I have already whitelisted “0.0.0.0/0” on MongoDB, which should theoretically allow all devices to access the database.
I suspect that it’s because I am fetching data from port 3001 like this
fetch(`http://localhost:3001/projects/${projectId}`)
which will no longer work on a different device. But I don’t know how to resolve this issue.
Any help would be appreciated. Thanks!