Just a day ago, I made a fullstack app. My folder structure goes like frontend and backend. I used vite.js for frontend and node.js for backend and used socket.io for communication. So here is the problem. When I ran my frontend localhost:5173 and backend on localhost:3000 it worked just fine. Then I uploaded my files to github and cloned them to render seperately for frontend and backend. They both went live but they can’t communicate. It says:
Blockquote
Access to XMLHttpRequest has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
Blockquote
I tried using cors(), header(), setHeader() everything. Nothing works. My project folder is here
I’m not entirely sure. Your code looks good at first glance, and we definitely wouldn’t mess with the CORS header. So, it’s either a misconfiguration I’m overlooking in your code, or an issue with the socket.io library, or maybe how you’re connecting to your backend—whether it’s through the socket or an HTTP call, and so on.