我们正在尝试使用 Iframe 在第三方客户端网站中访问我们的源网站。 根据建议,我们在源服务器的 nginx 中启用了以下配置
add_header X-Frame-Options "allow-from http://client-website.com" always;
add_header Content-Security-Policy "frame-ancestors 'self' http://client-website.com" always;
但现在的问题是, 在 Firefox 中,通过客户端网站访问它时,它工作正常,没有任何问题,但对于 chrome 和 safari,它会给出以下错误:
未捕获的 DOMException:阻止了具有原点的框架 “https://our-website.com”访问跨域框架。
火狐浏览器:版本:114.0.2 Chrome:版本118.0.5993.70
chrome 需要什么额外的东西才能使其工作吗?
您已允许 http://client-website.com,虽然请求来自 https://client-website.com,但方案有所不同。
此外,X-Frame-Options 似乎缺少“.com”,但当您实现frame-ancestors 指令时,大多数浏览器都会忽略它。它只会被 Internet Explorer 和其他非常旧的浏览器使用。