I am using a GeoServer docker image from here and running a docker container on CentOS Linux. GeoServer Docker
I have mounted Geoserver data directory as external and able to successfully run the GeoServer
I am able to get WFS request without any issue. However when I do Post on WFS. I am getting a CORS error. I am running my web server and docker on same server so IP is same but GeoServer runs 8080 and my NodeJS React app runs on 3000.
Access to XMLHttpRequest at 'http://XXX:8080/geoserver/VPS/ows' from origin 'http://XXX:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Tomcat in the docker container is CORS enabled by default. I tried to enable the CORS in GeoServer webapp folder also.
Still I am getting the same error.
What am I missing here to solve this CORS issue
And my Post call looks like below from React Axios
axios({
method: 'post',
headers: { "Access-Control-Allow-Origin": "*", "X-Frame-Options": "SAMEORIGIN", "Content-Type": 'text/xml' },
url:configData.gs_transactUrl,
crossdomain: true,
service: 'WFS',
version: '1.0.0',
dataType: 'xml',
processData: false,
RequestMethod: "POST",
contentType: 'text/xml',
typeName:configData.gs_typeName,
data: myXMLdata
}).then(function (response) {
//do something here
}
Access-Control-Allow-Origin
header. More on this can be found here: developer.mozilla.org/fr/docs/Web/HTTP/Headers/…