let headers = new Headers({
'Content-Type' : 'application/json'
});
let options = new RequestOptions({ headers: headers });
this.http.post('https://cors-anywhere.herokuapp.com/'+url, body, options)
.subscribe(data => {
let response = JSON.parse(data['_body']);
if (response.MessageCode == 'SUCCESS') {
this.loginMessage = 'success';
this.navCtrl.push(HomePage, response);
}
else {
this.loginMessage = 'failure';
}
}, error => {
console.log(error);
});
I'm having CORS issue. So, I used it before the URL to make it work.
Below is the config.xml
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<preference name="ScrollEnabled" value="false" />
<preference name="android-minSdkVersion" value="16" />
<preference name="BackupWebStorage" value="none" />
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="FadeSplashScreenDuration" value="300" />
<preference name="SplashShowOnlyFirstTime" value="false" />
<preference name="SplashScreen" value="screen" />
<preference name="SplashScreenDelay" value="3000" />
<plugin name="cordova-plugin-splashscreen" spec="^5.0.2" />
<plugin name="cordova-plugin-ionic-webview" spec="^1.1.16" />
<plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" />
<plugin name="cordova-plugin-device" spec="^2.0.1" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
<plugin name="cordova-plugin-advanced-http" spec="^1.11.0" />
Request headers-
Accept: */*
Accept-Encoding: gzip, deflate
Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
Access-Control-Request-Headers: content-type
Access-Control-Request-Method: POST
Connection: keep-alive
Host: 64.77.72.122
Origin: http://localhost:8100
Response headers-
Connection: close
Content-Length: 1245
Content-Type: text/html
Date: Thu, 15 Mar 2018 15:37:44 GMT
Server: Microsoft-IIS/8.5
X-Powered-By: ASP.NET
I have tried all the options mentioned in other similar questions like the one mentioned below.
Can someone address this issue? TIA.