DEV Community


Posted on


CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Hello! I'm trying to use GitHub Graphql and in some petitions, I get the error in the title.
Do you know how to solve it? I tried with a public proxy but I get anyway...

method: 'POST',
mode: 'cors',
origin: 'myapp.url',
body: JSON.stringify({query}),

Top comments (2)

ben profile image
Ben Halpern

I guess you're running this in the browser if you're getting this error.

Is this an endpoint which requires an API key? If that is the case I wouldn't be surprised if GitHub proactively restricts this because that wouldn't be advised.

Either way, you may need to run this on the server and then pass it along to the browser? Just a thought. There could be something else going on.

maluzzz profile image
MariLuz • Edited

Exactly, I run in the browser and my app requires API key to communicate with GitHub.
I don't use server-side so I was looking for a proxy solution or something like that.
But sometimes it is working fine and sometimes stops working, and I can't figure why

Thanks for your answer :D

Timeless DEV post...

Git Concepts I Wish I Knew Years Ago

The most used technology by developers is not Javascript.

It's not Python or HTML.

It hardly even gets mentioned in interviews or listed as a pre-requisite for jobs.

I'm talking about Git and version control of course.

One does not simply learn git