CORS, Angular and Nuxeo API
Hi.. I'm working with Angular and the Nuxeo API and have come across a weird issue. I can create documents but I cannot delete/update documents and I cannot upload files. The error I get is ..
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1:7000' is therefore not allowed access. The response had HTTP status code 405.
First here is my CORS config..
<?xml version="1.0"?>
<component name="org.nuxeo.cors">
<extension target="org.nuxeo.ecm.platform.web.common.requestcontroller.service.RequestControllerService" point="corsConfig">
<corsConfig name="api">
<pattern>/nuxeo/site/api/.*</pattern>
</corsConfig>
</extension>
</component>
Here's a snippet of my controller that deletes a document..
nuxeo.document('/default-domain/workspaces/test/testdoc')
.fetch()
.then(function(doc){
//There seems to be some CORS issue with this request
doc.delete();
$location.path('/');
});
Any assistance on this would be appreciated.
Hi,
You need to configure the supportedMethods
for your CORS config. By default, it only handles GET, POST, HEAD, OPTIONS. See the documentation.
...
<corsConfig name="api" supportedMethods="GET,POST,PUT,DELETE,HEAD,OPTIONS">
...