CORS and ionic emulate/run expert knowledge required

Hey all,

I am looking for some expert knowledge & advice on where CORS will and won’t be a problem. My understanding is that when using run, emulate and build Ionic should be serving from file:// so CORS isn’t a problem.

In practice, both $ ionic run and $ ionic emulate are still giving me CORS issues. When debugging using Safari, I can see that it’s serving from an IP address (and can also see the CORS error).

I have tried using ionic proxy, however I need to send headers through for authentication and ionic proxy seems to be quite limited in that area.


Make sure you have the whitelist plugin installed, and then add this to your index.html:

<meta http-equiv="Content-Security-Policy" content="font-src 'self' data:; img-src * data:; default-src * 'unsafe-eval' 'unsafe-inline'">

This defines a very permissive content security policy, which should hopefully solve any CORS issues.