我正在尝试将内容加载到IFrame中,因此我实现了Content-Security-Policy头部:Content-Security-Policy: frame-ancestors http://*.example.com/abc.html。
当我提供以下标头时,可以加载iframe中的内容: Content-Security-Policy: frame-ancestors http://*.example.com/。
但是当我更改标题为: Content-Security-Policy: frame-ancestors self http://*.example.com/abc.html。 然后,在刷新网页时,iframe中的内容在第一次加载时可以正常显示,但会出现以下错误:
因为祖先违反了以下Content Security Policy指令:frame-ancestors self http://*.example.com/abc.html,所以拒绝在框架中显示'https://....'。
有人能告诉我为什么在刷新页面时会出现错误吗? 另外,frame-ancestors是否考虑完整的URL(http://.example.com/abc.html)还是只考虑主机名,比如http://.example.com?