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".

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.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.