angularjs - Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at ..... -
when using $http.get have problem: cross-origin request blocked: same origin policy disallows reading remote resource @ ..... can fixed moving resource same domain or enabling cors
$http.get('...').success(function(data){ console.log(status); }).error(function(data){ //console.log(data) }); app.config(['$httpprovider', function($httpprovider) { $httpprovider.defaults.usexdomain = true; delete $httpprovider.defaults.headers.common['x-requested-with']; }
cross-origin requests requests made 1 domain different 1 (in client side). default prohibited in web security reasons. so, if have webpage in http://www.yours.com making ajax request http://www.other.com/get/resource, ajax request rejected. issue can resolved in 3 ways :
- fetch api (/get/resource) in http://www.yours.com request not cors request anymore.
- transform architecture of application, request http://www.yours.com made in backend (aka not in form of ajax) , passed on webpage.
- enable server in http://www.other.com allow cors requests http://www.yours.com. can done adding header
origin: http://www.yours.com
in responses of server. thus, requires have access second server's configuration.
additional resources cors :
Comments
Post a Comment