I am currently working on a little GIS web app using MapBox on the frontend and GeoServer as my WMS. I have GeoServer 2.15.0 running under Apache Tomcat 9.0.20. Both of them run on localhost but on different ports.

Problem is, when I want to get some data from GeoServer to load it into my app I get a CORS response.

I have followed many threads and the Apache Docs on how to enable CORS both for Tomcat and for GeoServer using the XML filter configuration. I've followed many answers but nothing seems to work.

As a side note, this only happens to me on Windows, at first I tested it on MacOS on my office computer and everything worked just fine on the first try. So then when I got home and repeated the process on Windows, it doesn't work, and I don't see what else I am missing.

On MacOS i installed Tomcat using Homebrew, on Windows using the Windows Service Installer. I installed GeoServer using the .war file.

This is the error I get on the console and the headers of the request. I am not sure if this is the best way to get JSON data from GeoServer, but it worked fine on the Mac. Following the recommendation, I deactivated Windows Firewall to test it but it still fails.

CORS error message

Request headers

  • are you sure it is a cors issue and not a windows firewall issue? Please add the headers and error messages to your question – Ian Turton Jun 24 '19 at 18:55
  • @IanTurton I am quite sure it is a CORS issue, because of the actual error it throws, but I am new to this software so I could be wrong. I updated the question with the information you asked for, if you need anything else just tell me, I'll keep trying to solve it also. – Luis Eduardo Cruz Caballero Jun 25 '19 at 1:02
  • how did you install GeoServer on the windows machine? – Ian Turton Jun 25 '19 at 7:09
  • @IanTurton I first installed Tomcat, with the Windows Service Installer. I tried to install GeoServer with the .war file using Tomcat's Manager App but it threw me a Timeout Exception. So I just copied the geoserver.war into Tomcat's webapp folder and used the Manager App to launch it. Then i just logged into GeoServer and changed the admin password as usual. In case you need to know, I put the CORS XML configuration in Tomcat and GeoServer using the configuration provided by each one (I also tried configuring it just in one at a time just to try). – Luis Eduardo Cruz Caballero Jun 25 '19 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.