CORS

Cross Origin Resource Sharing (CORS) was designed mainly to access resources from cross domains. Cross-domain policy does not apply to Cordova, so we don't have to think much about when testing on a device:

While running the same app on a browser it might gave a CORS error while accessing resources from the cross domain. When you run the ionic serve command you will see this issue. There are four methods to bypass it:

  • Disable Chrome security
  • Browser extension
  • Proxy server
  • The easiest and most convenient way is to run the application in Google Chrome with flag: --disable-web-security:
    $ google-chrome -disable-web-security $ chromium-browser ...

Get Hybrid Mobile Development with Ionic now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.