Showing posts with label cross origin. Show all posts
Showing posts with label cross origin. Show all posts

Tuesday, 22 March 2022

Enable geoserver to serve frond end and overcome the CORS problem

 Go to geoserver\lib in the lib directory of geoserve to find jetty-servlets-XX.jar and jetty-util-xx.jar (xx means different versions) two jar packages


Copy the all jars packagesfrom geoserver\lib to the geoserver\webapps\geoserver\WEB-INF\lib\ directory

 Go to the geoserver\webapps\geoserver\WEB-INF directory to find web.xml and add the following XML:


<context-param>

    <param-name>ENABLE_JSONP</param-name>

    <param-value>true</param-value>

</context-param>

<filter>

      <filter-name>cross-origin</filter-name>

      <filter-class>org.eclipse.jetty.servlets.CrossOriginFilter</filter-class>

  </filter>

   <filter-mapping>

        <filter-name>cross-origin</filter-name>

        <url-pattern>/*</url-pattern>

    </filter-mapping>



add the following line at the beginning of startup file of geoserver   

"C:\Program Files\GeoServer\bin\startup.bat" edit it by notepad++

set geoserver.xframe.shouldSetPolicy=false


or using the service 

open the wrapper folder C:\Program Files\GeoServer\wrapper

and edit the cmd command which placed at the end of the jsl64 file

-Dgeoserver.xframe.shouldSetPolicy=false



stop the service and run the startup.bat as administrator

Everything will be OK