我是Play Framework的新手,我试图将jquery CDN放到我的播放应用程序中。每次我将任何类型的CDN放入我的视图文件(scala.html扩展名)时,我都会收到一条CSP错误说:
Refused to load the script
'https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js' because
it violates the following Content Security Policy directive: "default-src
'self'". Note that 'script-src' was not explicitly set, so 'default-src' is
used as a fallback.
我提到How does Content Security Policy work?并相应地添加了元标记元素,并引用了http://content-security-policy.com/
但仍无法使其发挥作用。
如果有人能帮助我的话,我会非常感激。谢谢你提前!
答案 0 :(得分:1)
我认为问题出在application.conf
文件中,您没有正确设置参数play.filters.headers.contentSecurityPolicy
。
有关参考,请参阅this page
答案 1 :(得分:0)