Giter VIP home page Giter VIP logo

Comments (19)

yiludege avatar yiludege commented on July 24, 2024

这个问题已经好几位同学反馈了,我本地实在是难以复现

假如主应用为 host ,子应用代码会在 iframe 内部运行,而 iframe 的 src 就是设置为主应用的 host,按理来说不应该存在这个跨域的问题

首先排除一下主应用的代码污染问题 #54 ,在主应用的 html 的 head 第一个元素加一段这样的代码 <script>if(window.parent !== window) {window.stop()}</script> 看看还有没有这个问题

在看看看是 getTargetValue 函数报的错误,这个函数的第二个参数是个啥东西呢

方便的话有个最小的 demo 就好了,我可以一点点排查

from wujie.

fanqi7 avatar fanqi7 commented on July 24, 2024

加了<script>if(window.parent !== window) {window.stop()}</script>这个脚本,还专门给attrs的src设了一个空页面,还是报这个跨域错误

from wujie.

yiludege avatar yiludege commented on July 24, 2024

这就排除了主应用污染的问题,现在就是一个纯前端跨域报错的排查,我没有现场也没有复现的最小demo,难排查

from wujie.

fanqi7 avatar fanqi7 commented on July 24, 2024

环境依赖PC应用的容器,很难搞出一个在浏览器上的demo

from wujie.

yiludege avatar yiludege commented on July 24, 2024

这个问题已经有好几个反馈了,有线上地址也有本地localhost,有点不知道怎么查了,子应用的iframe和主应用都是同源的

from wujie.

fanqi7 avatar fanqi7 commented on July 24, 2024

还有cFetch报错,fetch子应用静态资源时报错
fetch报错

from wujie.

fanqi7 avatar fanqi7 commented on July 24, 2024

使用qiankun可正常加载子应用的静态资源

from wujie.

yiludege avatar yiludege commented on July 24, 2024

扎心了,给点信息

from wujie.

yiludege avatar yiludege commented on July 24, 2024

在我文章的评论区有位同学似乎找到了一些线索:
image

image

from wujie.

roy-kang avatar roy-kang commented on July 24, 2024

有可能是本地环境设置了 attrs 的 src

from wujie.

yiludege avatar yiludege commented on July 24, 2024

这个问题已经在常见问题中列出来了可能性,需要用户去排查一下

from wujie.

gadzan avatar gadzan commented on July 24, 2024

这个问题已经在常见问题中列出来了可能性,需要用户去排查一下

@yiludege 也有可能是父应用的 document.domain 被改变了导致的,建议加上这个排查项;

from wujie.

yiludege avatar yiludege commented on July 24, 2024

@gadzan 好的,这个地方父应用的 document.domain 被改变指的改到了其他域名还是只是三级域名改到二级域名也会出现这个问题呢,正常来说主应用的 domain 也不应该改成跨域的

from wujie.

gadzan avatar gadzan commented on July 24, 2024

@gadzan 好的,这个地方父应用的 document.domain 被改变指的改到了其他域名还是只是三级域名改到二级域名也会出现这个问题呢,正常来说主应用的 domain 也不应该改成跨域的

@yiludege 三级域名改到二级域名,准确来说是将 domain 改到父域,因为有时候需要操作父域的 Cookies, 所以会更改主应用 domain

from wujie.

swmjj avatar swmjj commented on July 24, 2024

官方例子中vue版主应用,主应用(VUE) 子路由(VUE3)的路由模式同时修改为hash模式,会出现这种问题

具体修改:
examples/main-vue/src/router/index.js

mode: "history" =》 mode: "hash",

examples/vue3/src/router/index.js

history: createWebHistory(basename) =》 history: createWebHashHistory(basename)

DOMException: Blocked a frame with origin "http://localhost:8001" from accessing a cross-origin frame.
at Wujie.mount (webpack-internal:///../../packages/wujie-core/esm/sandbox.js:529:96)
at eval (webpack-internal:///../../packages/wujie-core/esm/sandbox.js:451:35)

==============

但是vue主应用 vue2子应用同为hash模式,并没有异常

from wujie.

X-W-W avatar X-W-W commented on July 24, 2024

@gadzan 好的,这个地方父应用的 document.domain 被改变指的改到了其他域名还是只是三级域名改到二级域名也会出现这个问题呢,正常来说主应用的 domain 也不应该改成跨域的

@yiludege 三级域名改到二级域名,准确来说是将 domain 改到父域,因为有时候需要操作父域的 Cookies, 所以会更改主应用 domain

主应用 xxx.example.com
子应用 yyy.example.com
将主应用与子应用的document.domain都设置为example.com会出现当前的问题

将domain改到父域的原因是由于应用部署了单点登录,需要携带cookie信息才能访问
如果不设置相同domain,iframe里加载vite应用请求type=module的es模块资源时,请求无法携带cookie信息。

目前看到的相关的解决方案是通过nginx进行反代解决跨域问题,但未尝试,成功加载js后可能还是会出现这个问题(捂脸

from wujie.

webLoginjun avatar webLoginjun commented on July 24, 2024

我这里报错的情况是这样
image
请问一下这个如何解决呢

from wujie.

LJiangA avatar LJiangA commented on July 24, 2024

这个问题已经好几位同学反馈了,我本地实在是难以复现

假如主应用为 host ,子应用代码会在 iframe 内部运行,而 iframe 的 src 就是设置为主应用的 host,按理来说不应该存在这个跨域的问题

首先排除一下主应用的代码污染问题 #54 ,在主应用的 html 的 head 第一个元素加一段这样的代码 <script>if(window.parent !== window) {window.stop()}</script> 看看还有没有这个问题

在看看看是 getTargetValue 函数报的错误,这个函数的第二个参数是个啥东西呢

方便的话有个最小的 demo 就好了,我可以一点点排查

chrome_Ip5Wezdmmg
我这里的报错是这样的,请问一下如何解决呢?

1、在主应用的 html 的 head 第一个元素加一段这样的代码 <script>if(window.parent !== window) {window.stop()}</script>;加这段代码也还存在这个问题;
2、试了常见问题10中的解决方案1,也还存在这个问题。

from wujie.

Yang1998-jiale avatar Yang1998-jiale commented on July 24, 2024

这个问题已经好几位同学反馈了,我本地实在是难以复现
假如主应用为 host ,子应用代码会在 iframe 内部运行,而 iframe 的 src 就是设置为主应用的 host,按理来说不应该存在这个跨域的问题
首先排除一下主应用的代码污染问题 #54 ,在主应用的 html 的 head 第一个元素加一段这样的代码 <script>if(window.parent !== window) {window.stop()}</script> 看看还有没有这个问题
在看看看是 getTargetValue 函数报的错误,这个函数的第二个参数是个啥东西呢
方便的话有个最小的 demo 就好了,我可以一点点排查

chrome_Ip5Wezdmmg 我这里的报错是这样的,请问一下如何解决呢?

1、在主应用的 html 的 head 第一个元素加一段这样的代码 <script>if(window.parent !== window) {window.stop()}</script>;加这段代码也还存在这个问题; 2、试了常见问题10中的解决方案1,也还存在这个问题。

我也是这个问题,我主应用里嵌入了两个不同的子应用,A子应用出这个问题,B子应用正常

from wujie.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.