I have a cordova app (SPA) and need to make an XmlHttpRequest to a local network resource.
If the app is in remote mode, I am not able/allowed to define the necessary privateNetworkClientServer
capability (the app was actually rejected in the Windows Store because I defined this capability while remote mode was enabled). Without privateNetworkClientServer
XmlHttpRequests to the local network do not work.
If the app is in local mode, I can define the necessary privateNetworkClientServer
capability but I am also getting a lot of errors/warning:
CSP14312: Resource violated directive 'script-src ms-appx: data: 'unsafe-eval'' in Host Defined Policy: inline script. Resource will be blocked
This is probably because I am using jQuery to dynamically create/update the app contents, like $("#myelement").html(...) ?
So I am kind of stuck here. In both modes I am facing issues.
Is there any way to make a XmlHttpRequest to a local network resource without defining the privateNetworkClientServer capability? Is there any other way I should create the single page app, which is compatible with local mode?
It should be the Content-Security-Policy that caused this issue, see the connect-src document,
You can try to add your local network URL to the
connect-src
resource directive in yourindex.html
file's first metaContent-Security-Policy
's content. As the following code, you can replace YOUR NETWORK URL with your URL.