Skip to content
New issue

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

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

Already on GitHub? # to your account

[Help] React子应用,本地开发通过proxy访问后台,在主应用proxy无法工作 #3037

Closed
JinHe-PerkinElmer opened this issue Jan 16, 2025 · 1 comment

Comments

@JinHe-PerkinElmer
Copy link

JinHe-PerkinElmer commented Jan 16, 2025

What happens?

React子应用配置了proxy,本地开发可以访问后台接口:

devServer: {
      headers: {
      "Access-Control-Allow-Origin": "*",
      },
      port: 8000,
      proxy: [
        {
          context: ['/api' ],
          target: 'https://mydomain.test.com',
          changeOrigin: true,
        },
      ],
    },

这在子应用内如是正常工作的,但是把子应用集成到主应用的时候,api调用就不行了。

proxySandbox.js:182 Uncaught (in promise) TypeError: Illegal invocation
    at Object.set (proxySandbox.js:182:1)
    at t [as navigate] (oidc-client.min.js:8125:1)
    at eval (oidc-client.min.js:7752:1)

例如获取user detail接口在子应用8000端口
GET http://localhost:8000/api/v1/user/detail
正常返回user 信息;
但是在主应用3000端口返回的是主应用的HTML

最小可复现仓库

问题比较明显,没有提供线上demo

相关环境信息

  • qiankun 版本: 2.10.16
  • 浏览器版本:Version 131.0.6778.205 (Official Build) (64-bit)
  • 操作系统:Win10

补充

目前没有找到解决方案,希望可以提供一些帮助,谢谢(刚接触微前端,研究过single-spa,使用起来很费劲,所以想试试qiankun)。

Copy link

由于缺乏足够的信息(github、stackblitz、codesandbox等可复现仓库),我们暂时关闭了该 Issue。请修改(不要回复) Issue 提供最小重现以重新开启。谢谢。如果只是单独的技术咨询,可移步 https://qiankun.umijs.org/#-community 交流~

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 16, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant