嵌入 Apache 超集禁止的 X-Frame-Options

问题描述 投票:0回答:1

我想将 Apache Superset 嵌入到我的 React 应用程序中。

App.js:

import { useEffect } from "react"
import { embedDashboard } from "@superset-ui/embedded-sdk"
import "./App.css"

function App() {
  const getToken = async () => {
            return "token_value"
        }
  useEffect(() => {
    const embed = async () => {
      await embedDashboard({
        id: "dashboard_id", // given by the Superset embedding UI
        supersetDomain: "http://localhost:8088",
        mountPoint: document.getElementById("dashboard"), // html element in which iframe render
        fetchGuestToken: () => getToken(),
        dashboardUiConfig: {
          hideTitle: true,
          hideChartControls: true,
          hideTab: true,
        },
      })
    }
    if (document.getElementById("dashboard")) {
      embed()
    }
  }, [])

  return (
    <div className="App">
      <h1>How to Embed Superset Dashboard into React</h1>
      <div id="dashboard" />
    </div>
  )
}

export default App

npm 启动时出错:

“首先加载”http://localhost:8088/embedded/dashboard_id ?uiConfig=11,加载“sameorigin”中安装的“X-Frame-Options”指令。”

还有

“无法通过“DOMWindow”执行“postMessage”:指定的目标源(“http://localhost:8088”)与接收者窗口的源(“null”)不匹配。”

当我单击“在新窗口中打开网站”时,会出现:

“此页面旨在嵌入到 iframe 中,但看起来并非如此。”

如何修复 bug 和嵌入式 Apache 超集?

iframe apache-superset x-frame-options
1个回答
0
投票

添加 superset_config.py 解决了问题

TALISMAN_ENABLED = False
ENABLE_CORS = True
HTTP_HEADERS={"X-Frame-Options":"ALLOWALL"} 
© www.soinside.com 2019 - 2024. All rights reserved.