【问题标题】:Disabling CORS in Dashing在 Dashing 中禁用 CORS
【发布时间】:2016-09-07 15:51:01
【问题描述】:

我有一个在 server1 上运行的 dashing 实例和一个网络服务器 (server2),我想根据它们的选择在 iframe 中提供 dashing 仪表板。

使用本机 URL,我得到以下信息:
Refused to display 'http://server1:3030/dashboard1' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

我尝试将 Dashing 放在 server1 上的本地 Apache 反向代理后面,并将标头设置为允许。远程 Apache 服务器 (server2) 然后调用反向代理,但 Chrome 开发工具仍然说它被拒绝。
Refused to display 'http://server1/dashboard1' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

这是使用带有以下标头的反向代理 Apache:

  Header set Access-Control-Allow-Origin "*"
  Header set Access-Control-Allow-Methods "GET, OPTIONS, POST"
  Header set Access-Control-Allow-Headers "origin, authorization, accept"

真的不知道薄的工作原理或如何设置它的标题,我现在有点难过。我什至尝试通过 layout.erb 中的 http-equiv 元标记添加允许,但没有成功。

【问题讨论】:

    标签: cors dashing


    【解决方案1】:

    由于 dashing 使用 Sinatra,您可以在 Sinatra's Docs 中找到答案。我可以通过将以下内容添加到位于 dashing 目录中的 config.ru 文件中来完成此操作:

    configure do
      set :protection, :except => :frame_options
    

    其他参考:How do I get Sinatra to refrain from adding the X-Frame-Options header?

    【讨论】:

      猜你喜欢
      • 2019-04-25
      • 2021-06-29
      • 2013-11-02
      • 2019-12-24
      • 2017-05-14
      • 1970-01-01
      • 2022-06-21
      • 2016-02-14
      • 2013-06-20
      相关资源
      最近更新 更多