问题描述
如标题所述,我在使用x-frame-options: sameorigin
在iframe中显示页面时遇到问题
在寻找可能的解决方案时,我遇到了x-frame-options: allow-from url
,这没有什么区别。我所有的资源也都通过https提供。
同时使用x-frame-options: sameorigin
和x-frame-options: allow-from url
时,sameorigin标头被禁用。
此外,在here上找到了有关x-frame-options
的文档:
# ALLOW-FROM uri
This is an obsolete directive that no longer works in modern browsers. Don't use it. In
supporting legacy browsers,a page can be displayed in a frame only on the specified origin
uri. Note that in the legacy Firefox implementation this still suffered from the same problem
as SAMEORIGIN did — it doesn't check the frame ancestors to see if they are in the same origin.
The Content-Security-Policy HTTP header has a frame-ancestors directive which you can use
instead.
我目前已将上述frame-ancestors
实现为其他浏览器的支持,例如。 Chrome,Safari或Firefox,但IE11不支持。我不想删除这是一个安全层,以避免点击劫持。
有什么建议吗?
解决方法
如问题中所述,我发现在附加另一个x-frame-options
标头时,sameorigin
被禁用了。
所以我稍稍修改了标题,发现以下内容对于IE11来说是完美的,并且不影响其他浏览器:
res.set("X-Frame-Options","SAMEORIGIN,ALLOW-FROM url");