I am trying to send some HTTP requests from my angular.js application to my server, but I need to solve some cors errors.
An HTTP request equals this example:
functions.test = function(foo, bar) {
return $http({
method: 'POST',
url: api_endpoint + 'test',
headers: {
'foo': 'value',
'content-type': 'application/json'
},
data: {
bar:'value'
}
});
};
the first attempt ends with an error of some errors. Therefore, I implemented the following lines in my php server script:
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE, PUT');
header('Access-Control-Allow-Headers: X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding, X-Auth-Token, content-type');
The first error is now fixed.
Now the developer console (on Chrome) shows me the following errors:
angular.js: 12011 OPTIONS http: // localhost: 8000 / test (anonymous function)
423ef03a: 1 XMLHttpRequest cannot load http: // localhost: 8000 / test . Prepress response has invalid HTTP status code 400
and the network request looks as I expected (status 400 is also expected):

, ( ), OPTIONS POST. , ?