You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "Volker Braun (JIRA)" <ji...@apache.org> on 2017/08/07 13:31:00 UTC

[jira] [Commented] (CB-10143) Local file:// url XmlHttpRequests are not allowed in WKWebViewEngine

    [ https://issues.apache.org/jira/browse/CB-10143?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16116586#comment-16116586 ] 

Volker Braun commented on CB-10143:
-----------------------------------

There is a pretty good-looking implementation of intercepting file:// url XmlHttpRequests at https://github.com/oracle/cordova-plugin-wkwebview-file-xhr (I'm not affiliated, just found it today)

That is:
* Overwrite window.XMLHttpRequest
* Check path and answer file:// requests in plugin code

This is imho better than CB-10109 and what ionic currently does in that it doesn't require an internal web server (which has potential security issues, and needs to find a free port to work reliably)


> Local file:// url XmlHttpRequests are not allowed in WKWebViewEngine
> --------------------------------------------------------------------
>
>                 Key: CB-10143
>                 URL: https://issues.apache.org/jira/browse/CB-10143
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-plugin-wkwebview-engine
>            Reporter: Shazron Abdullah
>              Labels: wkwebview-known-issues
>
> mobile-spec failure in XMLHttpRequest.spec.4 is a known WKWebView issue, where CORS is now respected and cannot load files from file:// urls, only http*:// urls are allowed.
> With CSP off to rule things out:
> XHR to yourself of course works, but doesn't really make sense for
> real-world use. XHR to a sibling file, parent file, or any child file
> results in the error ""Cross origin requests are only supported for
> HTTP”.
> To illustrate:
> {code}
>   |
> parent.xml
>   |
> www
>   |---- index.html (file currently loaded)
>   |---- sibling.xml
>   |---- child-folder
>   |       |---- child.xml
> {code}
> index.html is the currently loaded file in the WebView. From it, you
> can't load parent.xml, sibling.xml nor child.xml using XHR according
> to my tests.
> The workaround is implementing CB-10109



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

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