CORS API 30 --> in Android readyState 4 is fine ,.status is 0 Fail , XMLHttpRequest


In Android Api 30 – 10.1.1 Fail…
Android readyState is 4 fine ,.status is 0 FAIL , XMLHttpRequest

In Android 9.0.0 Fine .

When you say it fails, can you be more specific?

Are there any error messages in the remote console?

    url                : is the page
   parameters  : parameters  post
        http_request.onreadystatechange = respuestaServidor;'POST', url, true);
        http_request.setRequestHeader('Access-Control-Allow-Origin', '*'); 
        http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        http_request.setRequestHeader('Access-Control-Allow-Headers', '*'); 
        http_request.setRequestHeader("Content-length", parameters.length);
        http_request.setRequestHeader("Connection", "close");

respuestaServidor is : :

function respuestaServidor() {
    f = document.form1;
    if (http_request.readyState == 4) {
        if (http_request.status == 200) {

-------> Compilacion in  9.0.0 .. functions Fine   is http_request.readyState is 4   and http_request.status is 200
-------> Compilacion in 10.1.1 .. function fail    is http_request.readyState is 4     and http_request.status is 0


Compile Good en 10.1.1 and 9.0.0
VoltBuilder run started at 2021-11-05 07:51:35.896769
Plan: Pro
Preflight Check
Output: Thanks for opting into telemetry to help us improve cordova.

Output: Creating a new cordova project.

Output: No version supplied. Retrieving version from config.xml...
Using cordova-fetch for cordova-android@10.1.1
fetch: Installing cordova-android@10.1.1 to 
Running command: npm install cordova-android@10.1.1 --save-dev
Command finished with error code 0: npm install,cordova-android@10.1.1,--save-dev
Removing "cordova-" prefix from cordova-android
Adding android project...
Loaded API for android project /node_modules/cordova-android
Creating Cordova project for the Android platform:
	Path: platforms/android
	Name: Comxxxx
	Activity: MainActivity
	Android target: android-30
Copying android template project to platforms/android
Subproject Path: CordovaLib
Subproject Path: app
Android project created with cordova-android@10.1.1...............

Tip : If you’re pasting code, html or config files, surround the code with triple back ticks (```), before the first line and after the last one. It will be formatted properly. (We fixed it for you this time)

Here’s how to check the remote console.


error messages in the remote console…

Access to Index.html:1

XMLHttpRequest at '' from origin 'https://localhost' 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. Failed to load resource: net::ERR_FAILED 

This is a common problem - it’s come up here several times before. There are new security requirements which apps need to follow.

There is more information in this document. Scroll down to White screen on startup