拒绝展示在框架中

Refused to display in a frame

我正在使用 iframe 在其上显示日历。但我不断得到以下信息;

Refused to display 'https://cal.mixmax.com/user1' in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self' https://mail.google.com https://inbox.google.com https://.force.com https://.mixmax.com".

我尝试将 Content-Security-Policy 的元数据设置如下,但没有成功。

<meta http-equiv="Content-Security-Policy" 
      content="frame-ancestors 'self' 
      https://mail.google.com 
      https://inbox.google.com 
      https://*.force.com 
      https://*.mixmax.com">

知道如何克服它吗?

问题不是你这边的配置错误,而是 Mixmax 那边的 CSP 指令。他们的页面上有以下指令:

content-security-policy:
  frame-ancestors 'self'
  https://mail.google.com
  https://inbox.google.com
  https://*.force.com
  https://*.mixmax.com;;
frame-src:
  https://*.stripe.com
  https://*.facebook.com
  https://*.mixmax.com;;

所以你不能加框,除非你来自任何列出的域。

解决这个问题的一种方法是在您的站点上创建代理,代表客户端访问 MixMax,并将数据发送到您的框架,因为 CSP 仅由客户端执行。