I installed GeoServer 2.12.1 on windows 8.1 x64 and I am trying to design a custom "login" form using AngularJS5 with Node.js, but when I make a request to geoserver it rejected by CORS, and get the error:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8080/geoserver/rest/. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

I read several questions here and follow the steps to enable CORS in geoserver by: downloading the matching "Jetty-Utility Servlets" jar file and putting it in the path:

C:\Program Files (x86)\GeoServer 2.12.1\webapps\geoserver\WEB-INF\lib

and also I uncomment the filters in the web.xml file and then restart geoserver .. but all that not worked with me.

I don't know what is wrong. As I said above I read several post about the problem but no luck.Like this question: Enabling CORS in GeoServer (jetty)?

The Solution: I used in my request headers, the Authorization header which doesn't allowed by default by CORS, so I added it explicitly in the web.xml file:

<init-param> <param-name>allowedHeaders</param-name> <param-value>Content-Type,X-Requested-With,accept,Origin,Access-Control-Request-Method,Access-Control-Request-Headers,Authorization</param-value> </init-param>

  • 2
    How have you installed Geoserver? using Tomcat & a WAR file? or using the jetty version? – Devdatta Tengshe Dec 25 '17 at 4:12
  • I installed GeoServer from it's website: geoserver.org and I choosed the stable version. I think it's jetty version!? I am so beginner in those things so I am not very sure. – abd0991 Dec 25 '17 at 9:17
  • 1
    what happens when you do curl -v -H "Origin: http://example.com" http://localhost:8080/geoserver/wfs\?service\=WFS\&version\=2.0.0\&request\=GetFeature\&typenames\=sf:bugsites\&filter\=%3Cfes:Filter%20xmlns:fes\=%22http://www.opengis.net/fes/2.0%22%3E%3Cfes:ResourceId%20rid\=%22bugsites.3%22/%3E%3C/fes:Filter%3E – Ian Turton Dec 25 '17 at 10:53
  • Here is the replay: Trying ::1... * TCP_NODELAY set * Connected to localhost (::1) port 8080 (#0) > GET /geoserver/wfs\?service\=WFS\ HTTP/1.1 > Host: localhost:8080 > User-Agent: curl/7.57.0 > Accept: */* > Origin: http://example.com > < HTTP/1.1 404 Not Found < Access-Control-Allow-Origin: http://example.com < Access-Control-Allow-Credentials: true < Access-Control-Expose-Headers: < X-Frame-Options: SAMEORIGIN < Content-Type: text/html; charset=ISO-8859-1 < Cache-Control: must-revalidate,no-cache,no-store < Content-Length: 298 < Server: Jetty(9.2.13.v20150730) – abd0991 Dec 25 '17 at 11:15
  • <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <title>Error 404 Not Found</title> </head> <body><h2>HTTP ERROR 404</h2> <p>Problem accessing /geoserver/wfs\. Reason: <pre> Not Found</pre></p><hr><i><small>Powered by Jetty://</small></i><hr/> </body> </html> – abd0991 Dec 25 '17 at 11:35

Browse other questions tagged or ask your own question.