I am implementing socket.io-client package in my react app. My react app is using express and webpack. When using following code:
import io from 'socket.io-client';
const socket = io('http://localhost');
in any component, I am getting following error:
polling-xhr.js:264 POST http://localhost/socket.io/?EIO=3&transport=polling&t=Lrprs_y 404 (Not Found)
Same error is coming when using http://localhost:80.
And when using 127.0.0.1 at the place of 'localhost`, its throwing following error:
XMLHttpRequest cannot load http://127.0.0.1/socket.io/?EIO=3&transport=polling&t=Lrq3G9W. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed access.
io('http://localhost:8080')and make sure that server is running - Shubham Khatri80. When usingio('http://localhost:80')still the same error. And when using127.0.0.1instead oflocalhostits throwing CORS error - Triyugi Narayan Mani