Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unsafe-eval error when CodePush (Cordova) meta tag is included

I have this error showing in my browser console:

Refused to execute inline script because it violates the following Content Security Policy directive: "default-src https://codepush.azurewebsites.net 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'". Either the 'unsafe-inline' keyword, a hash ('sha256-gpnLwpFw97DB28/JjA3G79AHgq5DtCgFiFwjahrA1d4='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.

It happens when add this line to de index.html file:

<meta http-equiv="Content-Security-Policy" content="default-src https://codepush.azurewebsites.net 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *" />
like image 300
Sergio Sadan Avatar asked Jan 21 '26 17:01

Sergio Sadan


1 Answers

Change meta tag to

<meta http-equiv="Content-Security-Policy" content="default-src https://codepush.azurewebsites.net 'self' data: gap: cdvfile: https://ssl.gstatic.com 'unsafe-eval' 'unsafe-inline' https: http: wss: ws:; style-src 'self' 'unsafe-inline'; img-src * filesystem: cdvfile: data:; media-src * blob:">

has fixed this issue for me.

like image 175
Saeid Doroudi Avatar answered Jan 24 '26 07:01

Saeid Doroudi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!