Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite子应用开启 iframe 沙箱,本地dev报 DOMException:Blocked a frame with origin "xxx" from accessing a cross-origin frame 等一些错误 #1360

Closed
LJiangA opened this issue Sep 12, 2024 · 2 comments
Labels
Need Reproduction 需要复现步骤

Comments

@LJiangA
Copy link

LJiangA commented Sep 12, 2024

问题描述

Vite子应用开启了 iframe 沙箱,且在主应用head的第一个元素插入了<script>if(window.parent !== window) {window.stop()}</script>

复现步骤

  1. Vite子应用开启了 iframe 属性:<micro-app name="vite-sub-app" url="http://localhost:5173/" iframe></micro-app>
  2. 在主应用haed的第一个元素插入了:<script>if(window.parent !== window) {window.stop()}</script>
  3. 打开子应用所在页面
  4. micro-app元素下没有head和body元素(图2),并报如下图1的错误

上传截图

  • 图1:
    image
  • 图2:
    image

环境信息

  • micro-app 版本:"@micro-zoe/micro-app": "^1.0.0-rc.9"
  • 主应用:Vue2+webpack
  • 子应用:Vue3+Vite
@LJiangA LJiangA changed the title Vite子应用开启 iframe 沙箱,本地dev报 DOMException:Blocked a frame with origin "xxx" from accessing a cross-origin frame 的错误 Vite子应用开启 iframe 沙箱,本地dev报 DOMException:Blocked a frame with origin "xxx" from accessing a cross-origin frame 等一些错误 Sep 12, 2024
@timhub66 timhub66 added the Need Reproduction 需要复现步骤 label Sep 12, 2024
Copy link

Hello @LJiangA. In order to facilitate location and troubleshooting, we need you to provide a realistic GitHub repository.
您好 @LJiangA, 为了方便定位和排查问题,我们需要您提供一个重现实例,请提供一个尽可能精简的 GitHub 仓库地址。

@LJiangA
Copy link
Author

LJiangA commented Sep 13, 2024

发现问题原因了,是主应用设置了 document.domain 导致的,但参考 #736 中的评论说是在1.0.0-beta.1已经解决了。有点疑惑这里还出现了类似的问题...

@LJiangA LJiangA closed this as completed Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Need Reproduction 需要复现步骤
Projects
None yet
Development

No branches or pull requests

2 participants