I have a weird problem with AngularJS and a REST webservice. This is my code:
$http.delete(appSettings['baseUrl'] + 'pricelistitem/' + article.itemNumber + '/' + article.acc)
.error(function(e) {
console.log(e);
});
When calling this, I'm getting an error and the .error
is executed, but the e
object is null
.
In the console, I'm getting 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 doing the DELETE request in postman (the same one which gets called by my code), I'm getting these headers in the reponse:
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 these headers are correct and I shouldn't get this error. Even if I did, the error object is null and so showing me no information at all.
UPDATE 15/06:
This issue occurs both when attempting to use PUT and DELETE. POST and GET works fine. In the network tab of Chrome dev tools, I can only see an OPTIONS request. In this request, Access-Control-Allow-Methods
is NOT present (but it is in the PUT/DELETE when testing this in Postman), even after configuring the Apache configuration to include this header in every response.
I've been working for hours on this problem without any result.
What could be causing this problem? Does the OPTIONS request also need to return the Access-Control-Allow-Origin header?
Any advice would be greatly appreciated!
No 'Access-Control-Allow-Origin' header is present on the requested resource
You are facing Cross Domain problem and what you should do is enabling CORS
from your server side.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With