Last Updated: September 09, 2019
·
9.528K
· avgp

CORSProxy - simple cross-origin AJAX for everything

Thanks to CORS cross origin AJAX has become pretty easy and painless.

But when I start playing around with APIs, I often find they don't set the headers and often they also don't provide a JSONP workaround.

Ignoring more painful options, that leaves the possibilities to use Yahoo Query Language or whip up your own custom proxy on some server using node.js, Ruby, PHP or whatever.

But there's another, even more comfortable option:

CORSProxy.com allows you to proxy every HTTP request you wish and gives you the response with the proper CORS header, so that your browser does not yell at you.

As an example, the Open Notify ISS Position API lacks both, JSONP (as far as I can tell) and CORS at the time of this writing.
Using CORSProxy, you can still get the data directly from the client side:

$.getJSON(" http://www.corsproxy.com/api.open-notify.org/iss-now/v1/", function(response) {
    console.log(response);
});

Painless, quick and easy.

Note: Don't use this for sensitive information. As long as you play around with publicly available data, fine. If you gonna use it for a production system, you will be smacked. If you have anything non-public or a "real live production" system, write your own little proxy for it. This method is supposed as a quick way to meddle with public APIs.

3 Responses
Add your response

The perfect solution! I was looking for something that would make that easy by adding the less code, but this solution is just the fastest I've ever found. Thanks for the share :) !

over 1 year ago ·

Does corspoxy support POST?

over 1 year ago ·

As far as I know, not :(

over 1 year ago ·