Alfresco 5.0.2 - 5.1
Procedure
Make sure "cors-filter-1.9.3.jar,java-property-utils-1.9.1.jar" is located in "/opt/alfresco/tomcat/webapps/alfresco/WEB-INF/lib".
Edit /opt/alfresco/tomcat/webapps/alfresco/WEB-INF/web.xml
Uncomment <filter> between <!-- CORS Filter Begin → and<!-- CORS Filter End -->
<!-- CORS Filter Begin --> <filter> <filter-name>CORS</filter-name> <filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class> <init-param> <param-name>cors.allowGenericHttpRequests</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>cors.allowOrigin</param-name> <param-value>http://localhost:8081</param-value> </init-param> <init-param> <param-name>cors.allowSubdomains</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>cors.supportedMethods</param-name> <param-value>GET, HEAD, POST, PUT, DELETE, OPTIONS</param-value> </init-param> <init-param> <param-name>cors.supportedHeaders</param-name> </init-param> <init-param> <param-name>cors.supportsCredentials</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>cors.maxAge</param-name> <param-value>3600</param-value> </init-param> </filter> <!-- CORS Filter End -->
Specify the URL to allow on the cross-domain to "cros.allowOrigin" param-value of the init-param element.
(The following asterisk specified here, but please specify with appropriate URL according to environment)
<init-param> <param-name>cors.allowOrigin</param-name> <!--param-value>http://localhost:8081</param-value--> <param-value>*</param-value> </init-param>
Uncomment <filter-mapping> between <!-- CORS Filter Mappings Begin --> and <!-- CORS Filter Mappings End --> .
<!-- CORS Filter Mappings Begin --> <filter-mapping> <filter-name>CORS</filter-name> <url-pattern>/api/*</url-pattern> <url-pattern>/service/*</url-pattern> <url-pattern>/s/*</url-pattern> <url-pattern>/cmisbrowser/*</url-pattern> </filter-mapping> <!-- CORS Filter Mappings End -->
Restart the Alfresco.
Alfresco 5.0.1
Procedure
Put cors-filter-2.4.jar and java-property-utils-1.9.1.ja.in /opt/alfresco/tomcat/webapps/alfresco/WEB-INF/lib directory.
Edit 'web.xml' in '/opt/alfresco/tomcat/webapps/alfresco/WEB-INF/' as shown below.
<filter> can be put anywhere on web.xml
But, <filter-mapping> must be put after "Global Localization Filter" and before "CMIS security context cleaning filter"
<filter> <filter-name>JSF Session Synchronized Filter</filter-name> <filter-class>org.alfresco.repo.web.filter.beans.SessionSynchronizedFilter</filter-class> </filter> <!-- ここから追加 Add descriptions start --> <filter> <filter-name>CORS</filter-name> <filter-class>com.thetransactioncompany.cors.CORSFilter</filter-class> <init-param> <param-name>cors.allowOrigin</param-name> <param-value>*</param-value> </init-param> <init-param> <param-name>cors.allowSubdomains</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>cors.supportedMethods</param-name> <param-value>GET, POST, HEAD, PUT, DELETE, OPTIONS</param-value> </init-param> <init-param> <param-name>cors.supportedHeaders</param-name> <param-value>Content-Type, Accept, Authorization</param-value> </init-param> </filter> <!-- ここまで追加 Add descriptions end --> <filter-mapping> <filter-name>Global Localization Filter</filter-name> <url-pattern>/*</url-pattern> <dispatcher>REQUEST</dispatcher> </filter-mapping> <!-- ここから追加 Add descriptions start --> <filter-mapping> <filter-name>CORS</filter-name> <url-pattern>/api/*</url-pattern> <url-pattern>/service/*</url-pattern> <url-pattern>/s/*</url-pattern> <url-pattern>/cmisbrowser/*</url-pattern> </filter-mapping> <!-- ここまで追加 Add descriptions end --> <filter-mapping> <filter-name>CMIS security context cleaning filter</filter-name> <url-pattern>/cmisws/*</url-pattern> </filter-mapping>
Restart the Alfresco.
Reference
About 'CORS'
Cross-origin resource sharing
W3C Cross-Origin Resource Sharing
Using CORS
Information about 'CORS' module in 'Alfresco'.