Cors issue, other answers did not fix (Solved - False Alarm)

Hello, when I run my client from the PlayCanvas.com editor I get the following CORS error:

Access to XMLHttpRequest at 'https://xxx.colyseus.dev/matchmake/create/Battle' from origin 'https://launch.playcanvas.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I know that cors is built into Arena now, so do I need to add a rule to grant access to 'https://launch.playcanvas.com'? If yes, how do I do that?

Thanks!

I tried adding the headers manually like so in the initializeExpress method of the arena-config file, but I still get the same error :(

app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});

Sorry, false alarm, the colyseus server was throwing a 500 internal error as the room was being created, the error response did not contain the CORS headers so that's why the browser was displaying the CORS error. Now to figure out why my room creation process is dying... :)

Hi, bitbeam!
Based on my experience, there's other reasons would cause this error:

  • Did not click "deploy" on Arena;
  • Reconnect to a Colyseus server

ref:
https://discuss.colyseus.io/topic/587/初学者常见错误与解决方法一览-持续更新

@coco Thanks for the additional information!