GitHub user gslin edited a discussion: Is there any way to bypass CORS requirement with native `fetch()`, on Android platform?
On Cordova 12, I want to access resources not controlled by myself (i.e. I can't add CORS in the response header), on Android platform. I know it's impossible on browser due to sandbox/security environment, but it should be possible on mobile platforms. This is my `www/index.html`: ```html <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>title</title> </head> <body> <textarea readonly style="height: 20rem; width: 100%"></textarea> <script src="cordova.js"></script> <script src="js/index.js"></script> </body> </html> ``` And this is `www/js/index.js`: ```js const main = async () => { const res = await fetch('https://www.example.com/'); const el = document.querySelector('textarea'); el.innerText = await res.text(); }; document.addEventListener('deviceready', main, false); ``` I've added `<access>` into `config.xml`, but it seems not working: ```xml <access origin="*" /> ``` The error message in the console is: ``` 10-30 05:07:12.365 14983 14983 I chromium: [INFO:CONSOLE(0)] "Access to fetch at 'https://www.example.com/' from origin 'https://localhost' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.", source: https://localhost/index.html (0) ``` GitHub link: https://github.com/apache/cordova/discussions/504 ---- This is an automatically sent email for issues@cordova.apache.org. To unsubscribe, please send an email to: issues-unsubscr...@cordova.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org For additional commands, e-mail: issues-h...@cordova.apache.org