I was running with the same problem, My ionic 3 app with ASP.net backend was working just fine, it was not working with IOS ( Iphone x – IoS 11 simulator ). I got some errors like the following.
[Error] failed to load resource: Preflight response is not successful.
[Error] Failed to load resource: Origin http://localhost:8080 is not allowed by Access-Control-Allow-Origin.
I’m not seeing this issue from the Android version of the application. Is there a setting or something that can be enabled within the Ionic app to fix the CORS issue?
Workaround only – Not a perfect solution
I changed the `web view` option of my ionic app.
WKWebView ===> UIWebView
First, open config.xml and add the following properties
<param name="ios-package" value="CDVWKWebViewEngine" />
<preference name="CordovaWebViewEngine" value="CDVWKWebViewEngine" />
then run the following commands – I hope you are familiar with this commands
ionic cordova plugin remove cordova cordova-plugin-ionic-webview --save
rm -rf platforms/
rm -rf plugins/
ionic cordova build ios
In iOS, there have been two webviews for a few years now, UIWebView and WKWebView. Historically, Ionic apps have used UIWebView, but no longer. Ionic now uses WKWebview by default when building for iOS.
We strongly believe WKWebview is the best option for any app, as it features many improvements over the older, legacy webview (UIWebView). These features include:
- JIT conversion of JS code down to machine code, which runs much faster
- Improved rendering performance
- Less memory consumption
- Better adherence to web standards
- Reliable scroll events (important for virtual-list)
We wanted to make sure that people could easily switch to WKWebView without many issues, but there are still some things that you’ll need to consider.
Reference : Ionic wkwebview