3
votes

I'm working with Ionic 4 and until now i made it work it without the webview plugin, but i dont know why/how the app can make cross-origin call without problems.

For me if i use some native plugin like cordova-plugin-file | cordova-plugin-camera i should have to install cordova-plugin-ionic-webview, but is not the case, the application is working fine with cordova plugin without the cordova-plugin-ionic-webview

But because i had to show images saved in the device (using the img tag) i had to install cordova-plugin-ionic-webview and after that the cross-origin doesn't work any more (the server don't return the good header).

So my question are:

  • Why i can use cordova plugin (access to native code) without cordova-plugin-ionic-webview
  • Why i can make cross-domain if i remove cordova-plugin-ionic-webview, even if the server don't return the good header (for me every ionic app is an webview)
  • Why adding cordova-plugin-ionic-webview make the CORS active ?
1

1 Answers

0
votes

Cordova plugins are generally not dependant on the webview type or other plugins like ionic-webview.

By default (without a plugin that changes the webview) cordova uses the iOS UIWebView component which does not enforce CORS policies.

The cordova-plugin-ionic-webview plugin will replace the UIWebView with the more recent WKWebView which does enforce CORS policies.