Cannot GET gist. No Access-Control-Allow-Origin header


#1

I’m trying to get a Gist by GETting the .json url. When I do, I get an Network Error like this:

Failed to load https://gist.github.com/laran/373ceb2d12502c8775991b54ccb07941.json: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:9999' is therefore not allowed access.

I’m calling the API using axios in the browser.

The Access-Control-Allow-Origin header is a response header as I understand it. So I’m stumped as to how to resolve this. I know this is a CORS issue. But I thought adding the Origin header would resolve it.

How can I get this to work properly?

Thanks!


#2

I figured this out by using jsonp. Wish the docs were better on this. I did eventually get it though.