MapStore and GeoServer containers CORS error

65 views
Skip to first unread message
Assigned to lorenzo...@geosolutionsgroup.com by me

Candan Eylül Kilsedar

unread,
May 23, 2025, 3:47:06 AMMay 23
to mapstore-developers
Hello, I enabled CORS in GeoServer by running the container in the following way:
docker run -it --name geoserverivrea --network ivreanetwork -p8081:8080 -d --mount type=bind,src=/home/kilsedar/geoserver_data,target=/opt/geoserver_data --env INSTALL_EXTENSIONS=true --env STABLE_EXTENSIONS="ysld,ogcapi-features,wps" --env CORS_ENABLED=true docker.osgeo.org/geoserver:2.27.1

I fact thanks to this, outside the container, I can get vector features, from a web application served by an Apache server. For example "http://localhost:8081/geoserver/ows?typeName=topp%3Astates&version=1.1.0&service=WFS&acceptversions=2.0.0&request=GetFeature&outputFormat=application%2Fjson&srsname=EPSG%3A3857" works from inside a web application.

However, inside the MapServer container, I keep getting CORS errors, such as:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://geoserverivrea:8080/geoserver/ows?typeName=ne%3Acountries&version=1.1.0&service=WFS&acceptversions=2.0.0&request=GetFeature&outputFormat=application%2Fjson&srsname=EPSG%3A3857. (Reason: CORS request did not succeed). Status code: (null).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://geoserverivrea:8080/geoserver/wps?service=WFS&version=1.0.0&REQUEST=DescribeProcess&IDENTIFIER=gs%3APagedUnique&acceptversions=2.0.0&request=GetCapabilities. (Reason: CORS request did not succeed). Status code: (null).

In the /usr/local/tomcat/webapps/mapstore/configs/localConfig.json of MapStore container I put, in "useCORS", both "http://geoserverivrea:8080/geoserver" and "http://localhost:8081/geoserver", but this didn't have any effect.

Do you have any idea what I may be doing wrong? Thank you very much!

 

Lorenzo Natali

unread,
May 27, 2025, 3:36:51 AMMay 27
to mapstore-developers
Hi,
if you have a CORS requests, means that MapStore correctly sends the CORS request, so probably you should work more on GeoServer's config. 
I'd suggest to see the effective request that fails and check the headers of the response, so you better identify the error and adjust your configuration.

Candan Eylül Kilsedar

unread,
May 27, 2025, 11:16:56 AMMay 27
to mapstore-developers
Thank you. I actually receive no response, but inside the request headers I don't see "Sec-Fetch-Mode: cors" that I see in my Apache web application (not a container, making a request to localhost:8081/geoserver), where I see the response from GeoServer with "Access-Control-Allow-Origin: *".
Actually now using "useCORS" on the MapServer side (making a request to geoserverivrea:8080), even getCapabilities request fails. Without CORS, I can see the layers in the Catalog and even add to the map, but for instance I cannot filter the layers.
Can this issue be because I am using a Docker network for MapStore and GeoServer?
Thank you!

Candan Eylül Kilsedar

unread,
May 29, 2025, 9:25:06 AMMay 29
to mapstore-developers
 I solved this by removing the Docker network. Thank you for your assistance.

Lorenzo Natali

unread,
Jun 3, 2025, 3:54:39 AMJun 3
to mapstore-developers
Great to know, 
and thank you for using MapStore.

Reply all
Reply to author
Forward
0 new messages