breautek commented on issue #352: Accessing cdvfile:// from http://[network-url] in ajax throws CORS policy error on Android URL: https://github.com/apache/cordova-plugin-file/issues/352#issuecomment-545069027 I briefly did some research and it looks like disabling CORS from the webview is not possible... but looks like it is possible to get around that by intercepting requests as shown [here](https://stackoverflow.com/a/34034037/4685664) And in case the link goes away, I'll post the example: ```java public class OptionsAllowResponse { static final SimpleDateFormat formatter = new SimpleDateFormat("E, dd MMM yyyy kk:mm:ss", Locale.US); @TargetApi(21) static WebResourceResponse build() { Date date = new Date(); final String dateString = formatter.format(date); Map<String, String> headers = new HashMap<String, String>() {{ put("Connection", "close"); put("Content-Type", "text/plain"); put("Date", dateString + " GMT"); put("Access-Control-Allow-Origin", /* your domain here */); put("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT, OPTIONS"); put("Access-Control-Max-Age", "600"); put("Access-Control-Allow-Credentials", "true"); put("Access-Control-Allow-Headers", "accept, authorization, Content-Type"); put("Via", "1.1 vegur"); }}; return new WebResourceResponse("text/plain", "UTF-8", 200, "OK", headers, null); } } ``` ```java // WebViewClient @Override @TargetApi(21) public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) { if (request.getMethod().equalsIgnoreCase("OPTIONS")) { return OptionsAllowResponse.build(); } return null; } ``` Not sure if this will work at all, and I can't promise when I'll have time to experiment with this.
---------------------------------------------------------------- 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: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
