Skip to content

Instantly share code, notes, and snippets.

@glennyboy
Last active October 29, 2020 10:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glennyboy/8fdcc2644ef3794206582c9452db3cb4 to your computer and use it in GitHub Desktop.
Save glennyboy/8fdcc2644ef3794206582c9452db3cb4 to your computer and use it in GitHub Desktop.
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