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 2021/02/24 12:47:57 UTC

[GitHub] [cordova-ios] breautek commented on issue #1082: Cordova not allowing https cross origin requests.

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


   This is a limitation of the WKWebView which Cordova can't really do anything about. Fortunately there are some workarounds though.
   
   You have three options:
   
   A) For accessing local files, it's best to use the cordova-plugin-file to read the file, where you can read the file as binary and make blob urls to be used in the DOM. However if this isn't possible for whatever reason, such as a framework assumption, then option B or C should be work for you.
   
   B) Use schemes. Schemes I don't think is documented yet, but it is explained in a [blog post](https://cordova.apache.org/howto/2020/07/18/uiwebview-warning.html). All `file://` requests are treated as a cross origin request because when on the `file://` protocol, your origin is null. Schemes will allow your app to make `app://` requests which wouldn't be considered cross origin. This will fix several other issues related to the app running on `file://` in the WKWebView as well. Note that when using schemes, your origin will change. This will result in your app using a different sandbox containers for your web storage, cookies, indexed db, etc. If preserving this data is important for your app, then you'll need to find a plugin to do the data migration.
   
   C) If you can't use schemes, then Oracle has a plugin that resolves XHR issues when using XHR on `file://` urls. Try installing [cordova-plugin-wkwebview-file-xhr](https://github.com/oracle/cordova-plugin-wkwebview-file-xhr). This approach will probbaly be the easiest to a working app but I would only recommend this approach as a last resort or a temporary measure. Migrating to schemes should probably be your goal.
   
   Since this isn't a bug, I'll be closing this issue. If you need more assistance, I welcome you to our [Slack](http://slack.cordova.io/) community where you can ask more questions.
   
   Kind Regards,
   Norman


----------------------------------------------------------------
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.

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