breautek commented on issue #1260: URL: https://github.com/apache/cordova-ios/issues/1260#issuecomment-1253118120
WKWebView enforces CORS and there is no way to disable that, but there are workarounds. If you have not already migrated to cordova-ios version 6, then these workarounds may not work. Therefore I recommend migrating to the latest version of cordova-ios@6 or later. If possible, you should be using [schemes](https://cordova.apache.org/announcements/2020/06/01/cordova-ios-release-6.0.0.html). To enable schemes, you can use this config in your `config.xml` ```xml <preference name="scheme" value="app" /> <preference name="hostname" value="localhost" /> ``` Using schemes will lift your app off the file protocol, which intentionally has several restrictions on the webview that are generally unavoidable or difficult to work around. However, if you have an existing app, changing from file-based app to a scheme based app will cause an origin change, and thus you'll lose access to any previously stored web storage data such as local storage or cookies. The data will still exists, but will remain inaccessible. Data migrations is out of scope of what Cordova can provide support for. If you must continue to use the file-protocol system (which is the cordova default), then you must use a third-party plugin that proxies XHR requests to conduct the HTTP request, rather than using the browser XMLHttpRequest feature, which is bounded by CORS. I know there are many users who have had success using [Oracle's plugin](https://github.com/oracle/cordova-plugin-wkwebview-file-xhr) that does just this. Switching to scheme solution should be the first option to consider, if possible. Only use the file-protocol system if you cannot make the switch or migrate to schemes. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
