CORS Error and Files Not Found


#1

No matter what I’ve tried, I cannot get the ionic app to connect to my website. It works with localhost and the site works just fine.

  1. I have cordova whitelist installed
  2. I have <allow-navigation href="http://*/*" /> in the config.xml (have also tried it with the specific website)
  3. I have set the proxy up and taken it off (I use it for localhost)
  4. I have this meta tag <meta http-equiv="Content-Security-Policy" content="default-src *; style-src &apos;self&apos; &apos;unsafe-inline&apos;; script-src &apos;self&apos; &apos;unsafe-inline&apos; &apos;unsafe-eval&apos;">

Let me know if you need more information.


#2

Have you tried to debug your mobile application? If you don’t know why tell me your mobile platform and OS and I’ll tell you how.

Next thing, you don’t need to change anything with config.xml, cordova whitelist plugin installation will make it open to everything.

Problem is usually in a meta tag. Some combinations will work for one service and utterly fail for other.

For example, this is a classic whitelist meta tag:

<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">

and it served me well until I tried to use Google Maps. They require completely different combination to be able to work:

<meta http-equiv="Content-Security-Policy" content="default-src *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; style-src  'self' 'unsafe-inline' *">