内容安全政策cordova问题

Jur*_*sma 0 cordova content-security-policy ionic-framework firebase-authentication

我在我的Windows PC上使用离子制作了一个应用程序,现在当切换到mac时我从控制台收到此错误

"拒绝加载 https://lorem.firebaseio.com/.lp?start=t&ser=59502592&cb=11&v=5, 因为它没有出现在Content Security的script-src指令中".

我已经尝试在我的标题中修改我的CSP标签,我似乎无法让它工作.我也尝试重新添加所有插件/平台/资源.

我现在使用的标签是

 <meta http-equiv="Content-Security-Policy" content="default-src * data: cdvfile: gap:; style-src 'self'  https://cdn.firebase.com https://*.firebaseio.com https://lorem.firebaseio.com/*; script-src 'self' 'unsafe-eval'">
Run Code Online (Sandbox Code Playgroud)

我也想知道为什么我不能像过去那样将它添加到我的白名单插件中

  <allow-navigation href="*"/>
  <allow-navigation href="http://192.168.178.13:8100"/>
  <allow-intent href="*.firebaseio.com"/>
  <allow-intent href="auth.firebase.com"/>
Run Code Online (Sandbox Code Playgroud)

----------------------------- edit -------------------- ---------

为了解决我的所有问题,我使用了这3个标签

content="default-src * data: cdvfile: gap:; 
      style-src 'self'  'unsafe-inline';
      img-src 'self' 'unsafe-inline';
      script-src 'self' https://lorem.firebaseio.com/* 
                        https://cdn.firebase.com
                        https://*.firebaseio.com
                        'unsafe-eval'">
Run Code Online (Sandbox Code Playgroud)

小智 8

您已在style-src部分添加了url,如果您尝试加载远程脚本源,则必须在script-src部分添加源URL .

<meta http-equiv="Content-Security-Policy" 
      content="default-src * data: cdvfile: gap:; 
      style-src 'self'  https://cdn.firebase.com
                        https://*.firebaseio.com
                        https://lorem.firebaseio.com/*;
      script-src 'self' https://lorem.firebaseio.com/* 'unsafe-eval'">
Run Code Online (Sandbox Code Playgroud)