Reputation: 2352
So I'm doing a cross origin request (have tried via AngularJS, AJAX, and XMLHttpRequest) neither of them allow me to set the headers. I can send requests POST, GET... with and without data and it works fine, as soon as I add headers:
xhr.setRequestHeader("user","someUser");
or AJAX
headers: {"user":"someUser"}
I get the error:
405 (Method Not Allowed)
XMLHttpRequest cannot load http://testsite.com Invalid HTTP status code 405
From the backend side of things I am allowing all origins:
header("Access-Control-Allow-Origin: *");
Not sure what the problem can be anymore...
Upvotes: 1
Views: 1841
Reputation: 279
var myApp = angular.module('myApp', [
'myAppApiService']);
myApp.config(['$httpProvider', function($httpProvider) {
$httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With'];
}
]);
Try adding this config....
Upvotes: 1