[iOS 12 Beta] Preflight requests fail

This issue happened due to the WKWebView Mostly

So, the very simple way to use the WKWebView in Ionic is that You Must uninstall the previously installed UIWebView from the plugin by running the following command.

  • ionic cordova plugin remove cordova-plugin-ionic-webview

After that try to add the WKWebView Plugin with this command

  • ionic cordova plugin add cordova-plugin-wkwebview-engine

When the WkWebView plugin is installed the very next thing is to add the following lines in the config.xml file

feature name=“CDVWKWebViewEngine”

param name=“ios-package” value=“CDVWKWebViewEngine”

feature

preference name=“CordovaWebViewEngine” value=“CDVWKWebViewEngine”

preference name=“WKWebViewOnly” value=“true”

After doing all that when you try to run the application and hit some api call you will get the preflight issue in that due to CORS so to fix that. Simply run the following command

  • ionic cordova plugin add cordova-plugin-wkwebviewxhrfix

After adding the above plugin the CORS issue will be resolved

Thanks,
Happy Coding