0

Essentially, I've been provided with a link to an API endpoint containing a JSON file. I'm aware of the limitations that are involved with cross-domain requests due to the 'single-origin' policy, but I was wondering if it is at all possible to request a JSON file from a remote server that does not already have the "Access-Control-Allow-Origin" header set up?

I would have included code, but I feel that the answer to this lies on the server-side and not so on the client-side JavaScript I've written.

  • If it’s not set up for cross-origin requests, you can’t make a cross-origin request to it. One method that predates CORS is JSONP; the API might support this. If it doesn’t, you’ll likely have to proxy it through a server of your own (or an equivalent service someone else provides). – Ry- Sep 06 '17 at 20:10
  • Pay particular attention to the section headed "Alternatives to CORS" in the accepted answer on the duplicate. – Quentin Sep 06 '17 at 20:11
  • 1
    Yes, it’s still possible. For an explanation of how to do it, see the **How to use a CORS proxy to get around “No Access-Control-Allow-Origin header” problems** section of the answer at https://stackoverflow.com/questions/43871637/no-access-control-allow-origin-header-is-present-on-the-requested-resource-whe/43881141#43881141. The gist of it is, you just need to prefix the request URL with `https://cors-anywhere.herokuapp.com/`. – sideshowbarker Sep 06 '17 at 20:11

0 Answers0