No. I am using Ionic Angular Cordova.
i have updated the network_security_config.xml as shown below
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="system" />
<certificates src="user" />
</trust-anchors>
</base-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">localhost</domain>
<domain includeSubdomains="true">mydomain.com</domain>
<domain includeSubdomains="true">api.mydomain.com</domain>
</domain-config>
</network-security-config>
Also, i have modified the config.xml
<platform name="android">
<access origin="*" />
<preferance name="android:usesCleartextTraffic" value="true" />
<allow-navigation href="*" />
<edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application" xmlns:android="http://schemas.android.com/apk/res/android">
<application android:networkSecurityConfig="@xml/network_security_config" />
<application android:usesCleartextTraffic="true" />
</edit-config>
And lastly, my node js Endpoint index.js has the below entries
const express = require(‘express’);
const app = express();
const cors = require(‘cors’);
app.use(cors());
app.use(express.json());
var http = require(‘http’);
http.createServer(function (request, response) {
response.writeHead(200, {
‘Content-Type’: ‘application/json’,
‘Access-Control-Allow-Origin’ : ‘*’,
‘Access-Control-Allow-Methods’: ‘GET,PUT,POST,DELETE’
});
});
// Here is used to import Routes
const thubsRoutes = require(’./users/routes’);
…
I have done everything but it is still not working.
My HTTP call from the ionic 5 application is :
addPerson(person:any): Observable {
this.httpHeader = {
headers: new HttpHeaders({ ‘Access-Control-Allow-Origin’:’*’,
‘content-type’: ‘application/json’,
‘Content-Type’: ‘application/x-www-form-urlencoded’,
‘Access-Control-Allow-Headers’:‘Origin, X-Requested-With, Content-Type, Accept’
})
};
console.log(person)
return this.http.post(this.baseURL + ‘login’, person,this.httpHeader)
}
Please assist.