0

I was adjusting my game locally but suddenly I were getting CORS errors. So I switched to Github where I had a working copy without any changes/adjustments but somehow even that wasn't working anymore.

My site: https://snake1v1.netlify.app/

When I check the Console log it shows me this:

Access to XMLHttpRequest at 'https://sleepy-island-33889.herokuapp.com/socket.io/?EIO=3&transport=polling&t=ODHUI9f' from origin 'https://snake1v1.netlify.app/' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
index.js:83

GET https://sleepy-island-33889.herokuapp.com/socket.io/?EIO=3&transport=polling&t=ODHUI9f net::ERR_FAILED 503

I've been using socket io V.2.3 and had to enable CORS manually via this code:

const http = require("http");
const socket_io = require("socket.io");

const httpServer = http.createServer();
const io = new socket_io.Server(httpServer, {
  cors: {
    origin: "https://snake1v1.netlify.app",
//        origin: "http://127.0.0.1:8080",
//        origin: "https://sleepy-island-33889.herokuapp.com/",
//        origin: "https://tranquil-refuge-03880.herokuapp.com/",
        methods: ["GET", "POST"]
  },
})();

I tried with different links but none of them work...

I also found this code snippet: Access-Control-Allow-Origin: *

I have two questions though, do I have to replace the * with my netifly or heroku domain? And where do I have to put in this code? In my server.json or index.html?

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
  • 1
    You are getting application error https://sleepy-island-33889.herokuapp.com/socket.io/?EIO=3&transport=polling&t=ODI2BX- it's not related to cors – Konrad Sep 18 '22 at 19:17
  • When you press on the sleepy island lock you'll get an application error. I had this application error when my site was still working too – Channel Supporter Sep 18 '22 at 19:51

0 Answers0