agea/CmisJS

HTTP status code 405

Closed this issue · 2 comments

How do I set up my code/ Tomcat server to allow my app to browse the repo?

I've tried so many ways to work around the problem but I keep getting the error below:

XMLHttpRequest cannot load http://localhost:8081/alfresco/cmisbrowser. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 405.

My code is very simple at this stage, a Meteor App, connecting to the repo with a hard coded URL and username/password.

Here is my code:

var url = url || "http://localhost:8081/alfresco/cmisbrowser";
var username = "admin";
var password = "xyzxyz";

var isNode = typeof module !== 'undefined' && module.exports;
var session = cmis.createSession(url);

session.setGlobalHandlers(console.log, console.log);

var rootId;

session.setCredentials(username, password).loadRepositories();```

I have tried to proxy alfresco through the Meteor port, trying to proxy meteor through Tomcat, tried proxying both through Apache httpd to try getting them to serve on the same port, but haven't been successful.

Any suggestions?
agea commented

It appears you are trying to access with the browser from http://localhost:3000 to http://localhost:8081 so it is a cross domain request, either you have to use a proxy (apache or nginx for example) in front of you applications, and serve them from the same domain, or you have to configure both meteor and Alfresco for CORS, I'm not sure if meteor already allows cross domain requests, for alfresco this can be a starting point: http://www.slideshare.net/jottley/cors-enable-alfresco-for-cors.

If you try to connect to alfresco server-side you should not face these issues.

Thanks for that link Andrea!
I have been able to get the access working by placing an nginx reverse proxy in front of both Meteor and Alfresco.

Having some more problems with Alfresco as the /alfresco/cmisbrowser does not reflect changes made in the alfresco-glabal.properties (as per https://forums.alfresco.com/forum/end-user-discussions/alfresco-mobile/androidios-alfresco-mobile-reverse-proxy-configuration) in the section

 # The servlet path, context path and server can all be selectively overridden
opencmis.context.override=true
opencmis.context.value=
# if true, the servlet path of OpenCMIS generated urls will be set to "opencmis.servletpath.value", otherwise it will be taken from the request url
opencmis.servletpath.override=true
opencmis.servletpath.value=
opencmis.server.override=true
opencmis.server.value=https://<my.public.alfresco.hostname>

But accessing the repository via the URL
/alfresco/api/-default-/public/cmis/versions/1.1/browser
seems to work OK