1

I'm using the layer tree control to manage the display of layers. When I add WMS services, it works fine. But when I add WFS, this is not loaded.

I'm using the Leaflet layer tree plugin code and GeoServer.

Below is the part of the code I use to add WFS layer on my main page:

...{ 
 "code": "space",
 "name": "space 1",
 "active": true,
 "selectedByDefault": false,
 "openByDefault": null,
 "childLayers": [],
 "selectType": null,
 "serviceType":"WFS",
 "params": {
            "request": "GetFeature",
            "service": "WFS",
            "styles":'',
            "outputformat": "application/json",
            "typeName": "rbrava:space_1",
            "url": "http://10.11.15.170:8080/geoserver/rbrava/wfs"
                      }
                    ...

I used the Chrome inspector and when I click on the layer checkbox to load that it gives me the following error:

"XMLHttpRequest cannot load... No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access".

nmtoken
  • 13,355
  • 5
  • 38
  • 87
mauricio santos
  • 409
  • 1
  • 4
  • 12

1 Answers1

1

No 'Access-Control-Allow-Origin' header is present

Well, there's your problem. You need to enable CORS on GeoServer.

CORS is somewhat tricky, and enabling it will depend on your installation of GeoServer, and any HTTP proxies you might be running.

IvanSanchez
  • 10,206
  • 2
  • 19
  • 35