I am creating a simple chat application. I am using JavaScript and NodeJS. But when I try to run the application it gives me this below error in the console.
Access to XMLHttpRequest at 'http://localhost:8000/socket.io/?EIO=4&transport=polling&t=NyWc1um' from origin 'http://127.0.0.1:5500' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
polling-xhr.js:157 GET http://localhost:8000/socket.io/?EIO=4&transport=polling&t=NyWc5p8 net::ERR_FAILED 200
Add the following header to your WebSocket server: Access-Control-Allow-Origin: * this allows all origins to access your server.