Skip to content

Instantly share code, notes, and snippets.

@dev0x10
Last active December 27, 2015 22:09
Show Gist options
  • Select an option

  • Save dev0x10/7397393 to your computer and use it in GitHub Desktop.

Select an option

Save dev0x10/7397393 to your computer and use it in GitHub Desktop.
Enable CORS in AngularJS
var app = angular.module("appname", []);
app.config(function($httpProvider) {
//Enable cross domain calls
$httpProvider.defaults.useXDomain = true;
//Remove the header used to identify ajax call that would prevent CORS from working
delete $httpProvider.defaults.headers.common['X-Requested-With'];
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment