[OpenLayers-Users] WFS layer Cross-Origin-Resource-Sharing not working

zachary at stauber.org zachary at stauber.org
Sun Jun 8 13:29:32 PDT 2014


Hello,


I’ve been able to use OpenLayers to reference a KML file on the same server as my OpenLayers script, inside an HTML file, but once have it pointing to a WFS service on a GeoServer that references a PostGIS table, it gives me the FireFox/FireBug error:


“Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://192.168.0.128:6443/geoserver/turner/wfs. This can be fixed by moving the resource to the same domain or enabling CORS.”



Interesting thing is it is all, in fact, on the same server (all same IP).  But the HTML/OpenLayers file is served up via Apache2 on port 443, and the GeoServer is on Tomcat’s port 6443.  But it will be on different servers eventually, so regardless I need to get this working.  Can anyone help?



I’m a GIS guy, not a web guy (yet), not a PHP guy, so I’ve seen some solutions suggesting a PHP proxy, but I don’t understand that, and I’d rather do it all in JS since I’m already using that for OpenLayers and supposedly it can all work through JS.



Here’s the stuff in my OpenLayers HTML file called earlyvoting2.html:



var earlyabsentee_wfs = new OpenLayers.Layer.Vector("Early Voting",{
     strategies: [new OpenLayers.Strategy.Fixed()],
     projection: map.displayProjection,
     protocol: new OpenLayers.Protocol.WFS({
      version: "1.1.0",
      srsName: "EPSG:4326",
      url: "https://192.168.0.128:6443/geoserver/turner/wfs",
      featureNS: "https://192.168.0.128:6443/geoserver/turner",
      featureType: "brown:earlyabsentee",
     })

});



I’m using IP’s because I haven’t bought a static IP certificate yet, but for purposes of this post let’s say in my intranet 192.168.0.128 is an Ubuntu 14.04 server named Turner, and everything is on it (PostGIS, Apache2, Tomcat, GeoServer, etc.).



I don’t quite understand, since I can bring the same layer in as a WMS link in a stubbed out OpenLayers page with one layer from the Layer Preview page in GeoServer, so it does CORS there.  But it hates WFS.



     -Zack Stauber
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20140608/36ebdcb0/attachment.html>


More information about the Users mailing list