Socket.io跨域如何解决?
老版本的Socket.io中是没有跨域问题的,但是新版本的socket.io中会重新跨域问题,下面我们就给大家看看Socket.io跨域如何解决?
参考:https://github.com/socketio/socket.io/issues/3755
const httpServer = require('http').createServer(app);
const io = require("socket.io")(httpServer, {
allowEIO3: true,
cors: {
origin: "*", // from the screenshot you provided
methods: ["GET", "POST"]
}
});