【问题标题】:Content-Security-Policy : allow frame-ancestors domain not workingContent-Security-Policy:允许框架祖先域不起作用
【发布时间】:2019-09-05 11:18:16
【问题描述】:

我想在我的 PHP 网页中嵌入一个 OpenStreetMap iframe;但我在任何网络浏览器中都有这种错误:

Content Security Policy: « x-frame-options » ignored due to the directive « frame-ancestors ».

但我确实添加了这段代码:

header( 'Content-Security-Policy: frame-ancestors openstreetmap.org' ) ;

我也看过这里(但没有帮助):

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors

https://developer.mozilla.org/fr/docs/Web/HTTP/Headers/X-Frame-Options

https://openweb.eu.org/articles/content-security-policy(法语)

怎么了?
谢谢

【问题讨论】:

  • 错误消息只是告诉您指定frame-ancestors 优先于x-frame-options,当两者都设置时。但是你不能从你的最后添加这个 - OSM 是必须允许他们的内容显示在你的 iframe 中的那个。如果这不起作用,那么也许您没有选择正确的资源开始嵌入?
  • 是的,非常感谢!

标签: php content-security-policy


【解决方案1】:

解决办法是嵌入正确的网址!

这个是错的:

https://www.openstreetmap.org/#map=11/48.8589/2.3469

但是这个没问题:

https://www.openstreetmap.org/export/embed.html?bbox=2.115554809570313%2C48.746228791937774%2C2.578353881835938%2C48.97165373099147

就是这样!

【讨论】:

    猜你喜欢
    • 2021-06-02
    • 2023-03-19
    • 2018-09-05
    • 1970-01-01
    • 2015-09-09
    • 2013-05-03
    • 2018-03-06
    • 2023-03-20
    • 2018-08-23
    相关资源
    最近更新 更多