The problems occurred when nodejs used socket.io are described in detail.

  node.js, question

In order to solve the problem of cross-domain access, I set the following code in the background:

app.all('*', function(req, res, next) {
 res.header("Access-Control-Allow-Origin", "*");
 res.header("Access-Control-Allow-Headers", "X-Requested-With");
 res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
 res.header("X-Powered-By",' 3.2.1')
 res.header("Content-Type", "application/json;  charset=utf-8");
 next();
 });

Then when using socket.io, the browser console reported the following error:

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access. The response had HTTP status code 404.

Pray for the great god to dispel doubts, thank you very much!

The reason has been found because the webserver listening port set in the background is the same as the socket.io listening port.