简体   繁体   中英

Socket.io Cross-Origin Resource Sharing Issue

We have our socket server hosted on AWS and it is connected with 4 URLs. The code base hasn't been changed for like 9 months but recently I'm getting an error.

The error:

Access to XMLHttpRequest at 'https:something' from origin 'https://something' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

GET https://something net::ERR_FAILED 522

The socket server CORS setting:

    cors: [{
        origin: process.env.CORS,
        methods: ["GET", "POST"]
    }, {
        origin: process.env.CORS2,
        methods: ["GET", "POST"]
    }, {
        origin: process.env.CORS3,
        methods: ["GET", "POST"]
    },{
        origin: process.env.CORS4,
        methods: ["GET", "POST"]
    },{
        origin: process.env.CORS5,
        methods: ["GET", "POST"]
    }]
});

We are using "socket.io": "^4.0.1"

Not sure how to fix this issue

Any help is much appreciated

我已经通过重启 AWS 服务器实例解决了这个问题

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM