DEV Community

MariLuz
MariLuz

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...
Thanks!

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

Latest comments (2)

Collapse
 
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.

Collapse
 
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