Skip to content

Instantly share code, notes, and snippets.

@glennyboy

glennyboy/Cors Anywhere Cross Origin Secret

Last active Oct 29, 2020
Embed
What would you like to do?
Cors Anywhere Cross Origin
//CORS Anywhere is a node.js proxy which adds CORS headers to the proxied request.
//To use the API, just prefix the URL with the API URL. (Supports https: see github repository)
////If you want to automatically enable cross-domain requests when needed, use the following snippet:
$.ajaxPrefilter( function (options) {
if (options.crossDomain && jQuery.support.cors) {
var http = (window.location.protocol === 'http:' ? 'http:' : 'https:');
options.url = http + '//cors-anywhere.herokuapp.com/' + options.url;
}
});
$.get(
// enter your URL below
'http://en.wikipedia.org/wiki/Cross-origin_resource_sharing',
function (response) {
console.log("> ", response);
$("#viewer").html(response);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.