You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/10/22 11:44:16 UTC

[GitHub] [cordova-plugin-file] vitto32 opened a new issue #352: Accessing cdvfile:// from http://[network-url] in ajax throws CORS policy error on Android

vitto32 opened a new 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
 
 
   While developing I run my app on an Android device. The app is served from a network url using cordova-plugin-webpack LiveReload (HMR) feature.
   
   I've successfully implemented a download mechanism of JSON files and Audio files.
   I can embed the downloaded audio file using `cdvfile` protocol (obtained through `.toInternalURL`)  but I can not get the JSON files using Ajax requests because of this error:
   
   > Access to XMLHttpRequest at 'cdvfile://localhost/files/test/data.json' from origin 'http://10.123.123.123:8080' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, https.
   
   Recap:
   - [x] I can access APIs on the web via ajax.
   - [x] I can download files using XHR and store them on the device.
   - [x] I can embed the downloaded files through src='cdvfile://'
   - [ ] I can't ajax 'cdvfile://'
   
   I have `<access origin="*" />` and also tried `<access origin="cdvfile://*" />` in config.xml
   I have `<allow-navigation href="cdvfile:*" />`
   CSP is set as follow:
   
   > default-src * cdvfile: data: blob: ws: wss: gap://ready file: http: https: 'unsafe-eval';
      media-src * cdvfile:;
       style-src * 'unsafe-inline';
       script-src * cdvfile: 'unsafe-inline' 'unsafe-eval';
       connect-src * ws: wss:;"
   
   Any help would be appreciated

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

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