enviroment
微前端框架
qiankun
error
控制台报错
single-spa.min.js?25a2:2 Uncaught TypeError: application ‘vue2’ died in status LOADING_SOURCE_CODE: Failed to fetch has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header
reason
这个报错的意思是主应用需要拉取的子应用vue2文档不允许跨域导致而出错
个人理解这是qiankun对子应用的要求:子应用需要允许跨域
resolution
当前子应用是vue+webpack的子应用,
在dev环境下修改webpack-dev-server的配置,使其html页面允许跨域
也就是添加配置 headers: { ‘Access-Control-Allow-Origin’: ‘*’ }
如果当前vue工程有webpack-dev-server配置,则直接添加
devServer: {
...headers: {