4 ms·
Is this Capacitor specific code? Here it seems the JS code can fetch data from any domain: https://github.com/kaangiray26/geddit-app/blob/main/src/js/geddit.j
by Timja 3y ago
Is this Capacitor specific code?
Here it seems the JS code can fetch data from any domain:
https://github.com/kaangiray26/geddit-app/blob/main/src/js/geddit.js#L24 https://github.com/kaangiray26/geddit-app/blob/main/src/js/g...
Since that is not possible in the browser, is that something Capacitor provides?
- tkzed49 3y agoyou can always fetch data from any domain, iff that server sets the correct CORS headers, unless I'm misunderstanding. https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
- Timja 3y agoMost servers don't set a CORS header though. So usually it does not work in the browser. Try this in your console while not on Reddit: fetch('https://www.reddit.com/.json')
- pxndxx 3y agoCORS is a browser security measure to protect users from malicious sites. This is an app and not a web browser and is therefore allowed to send HTTP requests to any URL it wants and to parse the HTTP responses as it deems necessary.