Hi FE !
Ai
git
前端面试题
前端小tip
  • vite
  • webpack
npm
  • vue2
  • vue3
react
GitHub
Ai
git
前端面试题
前端小tip
  • vite
  • webpack
npm
  • vue2
  • vue3
react
GitHub
  • 微应用需要支持跨域访问

微应用需要支持跨域访问

遇到这样报错:Access to fetch at ‘http://localhost:3000/’ from origin ‘http://localhost:8000’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource. If an opaque response serves your needs, set the request’s mode to ‘no-cors’ to fetch the resource with CORS disabled.

由于qiankun框架 解析微应用使用 import-html-entry库通过fetch请求相关资源,所以需要微应用支持跨域访问;在webpack devServer中加入以下代码即可

headers: {
  'Access-Control-Allow-Origin': '*'
},
Edit this page
最近更新: 2025/12/2 01:46
Contributors: qdleader
qdleader
本站总访问量 129823次 | 本站访客数 12人