diff --git a/ALFRESCOCORS.md b/ALFRESCOCORS.md new file mode 100644 index 0000000000..a5a06e092c --- /dev/null +++ b/ALFRESCOCORS.md @@ -0,0 +1,65 @@ +### Enable CORS in Alfresco + +The web client that we are building with the application development framework will be loaded from a different web server than the Alfresco Platform is running on. +So we need to tell the Alfresco server that any request that comes in from this custom web client should be allowed access +to the Content Repository. This is done by enabling CORS. + +To enable CORS in the Alfresco Platform do one of the following: + +**Download and install the enable CORS module** + +This is the easiest way, add the [enablecors](https://artifacts.alfresco.com/nexus/service/local/repositories/releases/content/org/alfresco/enablecors/1.0/enablecors-1.0.jar) +platform module JAR to the *$ALF_INSTALL_DIR/modules/platform* directory and restart the server. + +Note. by default the CORS filter that is enabled will allow any orgin. + +**Manually update the web.xml file** + +Modify *$ALF_INSTALL_DIR/tomcat/webapps/alfresco/WEB-INF/web.xml* and uncomment the following section and update +`cors.allowOrigin` to `http://localhost:3000`: + +``` + CORS + com.thetransactioncompany.cors.CORSFilter + + cors.allowGenericHttpRequests + true + + + cors.allowOrigin + http://localhost:3000 + + + cors.allowSubdomains + true + + + cors.supportedMethods + GET, HEAD, POST, PUT, DELETE, OPTIONS + + + cors.supportedHeaders + origin, authorization, x-file-size, x-file-name, content-type, accept, x-file-type + + + cors.supportsCredentials + true + + + cors.maxAge + 3600 + + +``` +When specifying the `cors.allowOrigin` URL make sure to use the URL that will be used by the web client. + +Then uncomment filter mappings: + +``` + CORS + /api/* + /service/* + /s/* + /cmisbrowser/* + +```