I did an Cordova application sending geodata (WFS) to a server (geoserver) using ajax xml. The server has CORS enabled as well as CORS Origin-Filters set (which is needed for browser-version, this filter is at the moment set to *, so any origin allowed). The POST-task works (!!) for up to Android 9, using Android 10 I get an "Error 403" because Android 10 sends Origin:file:// in the POST which means Origin "null" which causes this error.
I´ve read posts for hours and hours and tried to fix this, but I´m not able to do so.
Can anybody help me - would be very nice!
Here my js for the Ajax-Post
transactWFS = function (mode, f) {
var node;
switch (mode) {
case 'insert':
node = formatWFS.writeTransaction([f], null, null, formatGML);
break;
case 'update':
node = formatWFS.writeTransaction(null, [f], null, formatGML);
break;
case 'delete':
node = formatWFS.writeTransaction(null, null, [f], formatGML);
break;
}
var payload = xs.serializeToString(node);
$.ajax('https://server.com/geoserver/database/ows', {
type: 'POST',
dataType: 'xml',
processData: false,
contentType: 'text/xml',
data: payload,
}).done(function () {
//sourceWFS.clear();
});
};
html-head contains
<meta http-equiv="Content-Security-Policy" content="default-src *; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data:">
config.xml contains
<plugin name="cordova-plugin-whitelist" source="npm" spec="~1.3.4" />
<access origin="*" />
<allow-navigation href="*"/>
After some days of work I could fix this problem by updating apache tomcat server to new version! This fixes the problem using CORS filter *