oracle / cordova-plugin-wkwebview-file-xhr

Cordova Plugin for WebView File XHR
Universal Permissive License v1.0
138 stars 120 forks source link

XMLHttpRequest not working in WKWebView due to CORS restriction #24

Closed vsvikram closed 5 years ago

vsvikram commented 5 years ago

Description: I'm making requests to an API endpoint from Cordova iOS app using $http.get() method which results in the CORS restriction errors. ERROR: xmlhttprequest cannot load Preflight response is not successful Observations:

  1. The server sends Access-Control-Allow-Origin response header
  2. Requests are completed when the app is run in Xcode simulator but failed on actual iPad

How can I overcome this issue or is there a workaround for this in WKWebView apps? Please let me know if more details are required.

gvanmat commented 5 years ago

@vsvikram By default he plugin will only intercept secure requests. Please review the configuration section of the readme.

InterceptRemoteRequests: all|secureOnly|none (default: secureOnly)

If you want the plugin to intercept unsecure requests, you need to add the following preference to your config.xml

<preference name="InterceptRemoteRequests" value="all"/>

vsvikram commented 5 years ago

Thanks @gvanmat . I missed that and assumed the URL endpoint we are using is secure https.