当我在运行Android 5的手机上运行Android Studio中的离子应用程序时,不会显示任何图像,我会为每张图像收到此消息:
Refused to connect to 'http://192.xxx.x.xxx:3000/promotions/0' because it violates the following Content Security Policy directive: "default-src 'self'". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.
在content-security-policy.com上,我找到并尝试了以下内容:
Starter Policy
This policy allows images, scripts, AJAX, and CSS from the same origin, and does not allow any other resources to load (eg object, frame, media, etc). It is a good starting point for many sites.
default-src 'none'; script-src 'self'; connect-src 'self'; img-src 'self'; style-src 'self';
但仍然没有运气。事实上,我已经尝试了许多内容安全策略的排列,但都没有成功。 我在使用时与使用Android Studio相同:
ionic build android
ionic run android
图像存储在运行正常的JSON服务器上,一切都可以在计算机上的localhost上正常工作。
解决此问题的任何指示?感谢
答案 0 :(得分:0)
尝试在头部添加此元数据
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval' ">