Since the introduction of the cordova-whitelist-plugin and Content Security Policy we have to add rules if we want to external ressources (ajax/scripts/css/images).
Today I stumbled on a problem with livereload on an android device. If you don’t add some special rule the livereload script is not evaluated due to the CSP and you’ll have an error like this
Refused to load the script 'http://192.168.0.99:35729/livereload.js?snipver=1' because it violates the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' 'unsafe-eval'".
and therefore no livereload functionality.
I don’t know if livereload is used a lot by ionic developers here but for me this CSP tag solved the problem
Replacing script-src 'self' with script-src * should fix it as a workaround. I say as a workaround because it’s not very good from a security point of view.
And yes it would be nice if the ionic starter templates already included some working CSP rules. I’ll look into submitting a patch when I have some time.
CSP pretty much breaks my ionic run development flow when it comes to live reload.
Isn’t there something that can be done to avoid * or specifying one or more IP addresses for script-src. Both options kinda beat the point of CSP.
I don’t know if things have changed on android since this post (or maybe I am doing something slightly different) but I found that for remote loading of scripts (such as weinery) on a local network IP address I need to declare the IP address in both script-src AND connect-src: