Monday, 27 January 2020

Allow cross origin in leaflet (Access-Control-Allow-Origin)

Step 1.

Copy the zar file at the location-
C:\Program Files (x86)\GeoServer 2.12.1\webapps\geoserver\WEB-INF\lib


Step 2. 
Modify the web.xml file at the locaiton- 
C:\Program Files (x86)\GeoServer 2.12.1\webapps\geoserver\WEB-INF


   <!-- Uncomment following filter to enable CORS -->
   <!--<filter>
        <filter-name>cross-origin</filter-name>
        <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
    </filter>
  -->
To
   <!-- Uncomment following filter to enable CORS -->
   <!-- -->
   <filter>
        <filter-name>cross-origin</filter-name>
        <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>
    </filter>




and

<!-- Uncomment following filter to enable CORS -->
    <!--<filter-mapping>
        <filter-name>cross-origin</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
     -->
To

  <!-- Uncomment following filter to enable CORS -->
    <!--  -->
  <filter-mapping>
        <filter-name>cross-origin</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping> 

Step 3. Restart the geoserver.

No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...