You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2022/10/01 02:08:55 UTC

[GitHub] [cordova-ios] breautek commented on issue #1242: Angular zone changes during http calls in cordova on iOS

breautek commented on issue #1242:
URL: https://github.com/apache/cordova-ios/issues/1242#issuecomment-1264199404

   Then it seems like a bug with zone.js, not with cordova-ios.
   
   Cordova doesn't implement webview features or the general JavaScript API. What Cordova does do is package web assets into a native wrapper with the system webview, and provide an API for JS to call on native device APIs, in some cases polyfilling certain features. Networking is not one of those features that gets polyfilled by Cordova.
   
   Monkey patching is also questionable practice and can lead to incompatibles between two independent systems attempting to monkey patch the same object. Which is likely what is happening here.
   
   You have zone.js which supposedly patches all async APIs, which I presumably also includes `fetch` and `XMLHttpRequest`, and you have `@globules-io/cordova-plugin-ios-xhr`, while I'm not familiar with this plugin specifically, "xhr fix" plugins generally work by monkey patching `fetch` and/or `XMLHttpRequest` to conduct an http request using the native device APIs instead of using the browser's network stack. This works because the native APIs aren't bounded by any CORS restrictions.
   
   XHR fix plugins are usually required to get around CORS when using XHR to fetch local assets (in the `file://` protocol). Using schemes is another way to get around cors and should eliminate the need for an XHR fix plugin, but it does change your app origin from `null` to whatever what you choose for your scheme (cordova defaults to `app://localhost` if schemes are enabled). This means if you use web storage such as local storage or cookies, they will become inaccessible as these storage containers are bounded to an origin.
   
   Migration is possible but out of scope of Cordova can provide assistance for. Generally speaking, using schemes is probably the best thing to do cause not only does it workaround CORS, but it also removes some other restrictions related to the `file://`, but the data migration can be a big hurdle if the stored data is important and isn't re-constructible. No one actually got around to documenting schemes yet, but examples are available in some [blog posts](https://cordova.apache.org/howto/2020/07/18/uiwebview-warning.html).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org