You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Angular Azure静态Web应用iframe跨域DOMException问题求助

问题

我有一个基于Angular开发的Web应用,通过iframe展示外部Azure Function API返回的HTML内容,该单页应用(SPA)托管在Azure Static Web App上。本地运行时页面正常,iframe能正确显示内容,但部署到云端后出现跨域错误:

DOMException: Failed to read a named property 'document' from 'Window': Blocked a frame with origin "xy.domain.com" from accessing a cross-origin frame.

本地环境中,我通过创建proxy.conf.json配置代理解决了跨域问题,配置内容如下:

{
  "/api/myendpoint": {
    "target": "http://127.0.0.1:7071",
    "secure": false,
    "logLevel": "debug",
    "headers": {
      "connection": "keep-alive"
    }
  }
}

请问Azure Static Web App是否支持这种代理方式?我尝试使用以下proxy.conf.json配置但无效:

{
  "/api/myendpoint": {
    "target": "https://myendpointXXX.azurewebsites.net/",
    "secure": false,
    "logLevel": "debug",
    "headers": {
      "Connection": "keep-alive"
    }
  }
}

内容的提问来源于stack exchange,提问作者pbachman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.05 03:14:55