CSP not working by default (Chrome App) #7391
Description
I'm using Angular 1.2.16 and I'm getting a bunch of the following error when launching my app as a chrome app:
Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in
the following Content Security Policy directive: "default-src 'self' chrome-extension-resource:". Note
that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.
The Angular Chrome App documentation states that the ng-csp
is no longer necessary:
However, if you're using an older version of Angular between v1.0.1 and v1.1.0, you'll need tell
Angular to run in a "content security mode". This is done by including the ngCsp directive alongside
ngApp:
I've tried setting the ng-csp
directive in my HTML to see if it would help and it does fix those errors (but most of my ng-if
s and ng-show
s are still broken 👎). That being said, I'd rather avoid ng-csp if it is not necessary (since it's slower I'd rather only use it on my chrome packaged app).
Any tips? Is this a known bug?
Update: I also tested with Angular 1.3, same bug
Update: I just fixed the ng-if/ng-show problem by manually including angular-csp.css
: <link rel="stylesheet" href="bower_components/angular/angular-csp.css" />
.
Adding ng-csp directive now fixed the obvious bugs. That being said, I'm a bit worried that this will degrade performance on the hosted version of my app. Is my worry justified? Is there any easy way to conditionally enable ng-csp/angular-csp.css without having to maintain 2 different index.html
files?