[RESOLVED] 'Access-Control-Allow-Origin' header is present on the requested resource


Hey Community!

I was attempting to get data from this page:


It worked, but I got the following error:
'Access-Control-Allow-Origin' header is present on the requested resource.

I know this is a CORS error, but I don’t know how to allow it to get the JSON file on a different glitch project.



So you’re trying to get https://discord-channel-bot.glitch.me/stats from another Glitch project and getting that error?

This might help if discord-channel-bot uses express


I see. I’m currently using Jquery right now tho. Would this code go on the data side or the GET side? The data side has express.


Never Mind! It worked! I put it on the data side, and I don’t seem to get the error anymore!



Paste the following code before any other express code:

  res.header("Access-Control-Allow-Origin", "*");
  res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");


Oh great, yeah was just checking it and looked right!