Instantly share code, notes, and snippets.

@essoen /web.xml
Last active Sep 4, 2018

Embed
What would you like to do?
CORS * for GeoServer with Tomcat add following to `/var/lib/tomcat7/webapps/geoserver/WEB-INF/web.xml`
<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>
</filter>
<filter-mapping>
<filter-name>CorsFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
@essoen

This comment has been minimized.

Copy link
Owner Author

essoen commented Jun 10, 2016

See here for reference.

@jukkatolonen

This comment has been minimized.

Copy link

jukkatolonen commented Mar 21, 2017

Plus if you use authentication add also:

  <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, Authorization</param-value>
  </init-param>
@JianxunRao

This comment has been minimized.

Copy link

JianxunRao commented Aug 7, 2018

That‘s awesome!It saved my time.Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment