1

I am using Mapbox Gl JS to get mapbox vector tiles (pbf) from GeoServer 2.15, which I am running with Tomcat 8.5 on a Windows Server. The Mapbox GL JS javascript is in a folder in the Tomcat webapps directory. Tomcat has been configured for CORS by editing the web.xml to include:

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

I have also added URL rewrite within IIS which links port 80 to Tomcat/GeoServer on port 8080. When opening the map in browser on another machine everything but the vector tiles from GeoServer displays. This is the error message I get:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8080/geoserver/gwc/service/tms/1.0.0/webmap:target_status@EPSG%3A900913@pbf/6/53/25.pbf. (Reason: CORS request did not succeed).

I have also noticed that X-Frame is set to SAME ORIGIN for the vector tiles.

Is there anything else missing or wrong with my setup? I would like to be able to open the web map through the URL and for the layers to be displaying? Is the CORS issue coming from IIS or Tomcat?


Edit: Just wanted to clarify that GeoServer itself is working as I can access it from another machine, through the URL. It is just the vector tiles which are generating the CORS error when viewing the map.

  • GeoServer itself can be accessed but the layers in the application cannot. – OG1_Mapper May 1 '19 at 6:37