Created
March 3, 2016 17:23
-
-
Save oculushut/1f2876ac2bd96aaf28d9 to your computer and use it in GitHub Desktop.
Opening up tomcat for Cross-Origin Resource Sharing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!--Push this into the web.xml of the service you want to open up--> | |
| <pre> | |
| <filter> | |
| <filter-name>CorsFilter</filter-name> | |
| <filter-class>org.apache.catalina.filters.CorsFilter</filter-class> | |
| <init-param> | |
| <param-name>cors.allowed.origins</param-name> | |
| <param-value>*</param-value> | |
| </init-param> | |
| <init-param> | |
| <param-name>cors.allowed.methods</param-name> | |
| <param-value>GET,POST,HEAD,OPTIONS,PUT</param-value> | |
| </init-param> | |
| <init-param> | |
| <param-name>cors.allowed.headers</param-name> | |
| <param-value>Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers</param-value> | |
| </init-param> | |
| <init-param> | |
| <param-name>cors.exposed.headers</param-name> | |
| <param-value>Access-Control-Allow-Origin,Access-Control-Allow-Credentials</param-value> | |
| </init-param> | |
| <init-param> | |
| <param-name>cors.support.credentials</param-name> | |
| <param-value>true</param-value> | |
| </init-param> | |
| <init-param> | |
| <param-name>cors.preflight.maxage</param-name> | |
| <param-value>10</param-value> | |
| </init-param> | |
| </filter> | |
| <filter-mapping> | |
| <filter-name>CorsFilter</filter-name> | |
| <url-pattern>/*</url-pattern> | |
| </filter-mapping> | |
| </pre> | |
| <!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS --> | |
| <!-- http://tomcat.apache.org/tomcat-7.0-doc/config/filter.html#CORS_Filter --> | |
| <!-- http://tomcat.apache.org/tomcat-7.0-doc/images/cors-flowchart.png --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment