I have a weird problem with AngularJS and the REST web service. This is my code:
$http.delete(appSettings['baseUrl'] + 'pricelistitem/' + article.itemNumber + '/' + article.acc) .error(function(e) { console.log(e); });
When you call this, I get an error and a .error is executed, but the object is e null .
In the console, I get this error:
XMLHttpRequest cannot load <url>. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:5000' is therefore not allowed access.
When you make a DELETE request at the postman (the one that is called by my code), I get these headers in the response:
Access-Control-Allow-Methods β GET, POST, PUT, DELETE, OPTIONS Access-Control-Allow-Origin β * Content-Length β 2 Content-Type β application/json Date β Fri, 29 May 2015 06:26:00 GMT X-Powered-By β IBM i
I would say that these headers are correct and I should not get this error. Even if I did, the error object would be null and therefore would not show me any information.
UPDATE 15/06: This problem occurs when trying to use PUT and DELETE. POST and GET are working fine. On the Network tab of Chrome dev tools, I can only see the OPTIONS request. Access-Control-Allow-Methods NOT present in this request (but it is in PUT / DELETE when testing this in Postman), even after configuring Apache to include this header in every response.
I have been working for hours on this issue without any results.
What can cause this problem? Does the OPTIONS request also need to return the Access-Control-Allow-Origin header?
Any advice would be greatly appreciated!