微应用需要支持跨域访问
遇到这样报错: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': '*'
},