-1

instructional URL/link of enabling CORS for GeoServer

File location/Directory

File location

As given on the website, I uncommented my the filter in web.xml file to enable CORS,

uncommented block 1

uncommented block 2

but now I can not access the GeoServer service.

after enabling CORS

and even after returning the web.xml file to original format. I am not able to access the WMS layers, because instead of opening the layer in new tab, it is downloading it as WMS file.

WMS file downloading instead of opening the layer

so have to remove and reinstall the whole GeoServer.

How do I rectify this issue?

0

3 Answers 3

3

The instructions on the website work for the Jetty container used in the "bin" distribution. However, you deployed on Tomcat, which would require a different set of declarations. See other answers here, specifically targetting Tomcat.

0
1

As Romah points out you have not uncommented the filter correctly - an XML comment is <!-- ..... --> so you need to remove the entire <!-- and --> in order for the web.xml file to be valid.

0

I recently had the same issue. Assuming you have Tomcat underneath, try this:

  1. Ignore the filters which were already in the file but commented. Comment them back.

  2. Add this instead:

     <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>
     </filter>
     <filter-mapping>
         <filter-name>CorsFilter</filter-name>
         <url-pattern>/*</url-pattern>
     </filter-mapping>
    

EDIT: This goes before the first <filter-mapping> tag

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.