首页 > 建站教程 > 前端框架 >  qiankun.js 提示died in status LOADING_SOURCE_CODE: Failed to fetch正文

qiankun.js 提示died in status LOADING_SOURCE_CODE: Failed to fetch

qiankun.js本地测试没问题,子应用打包放到nginx后,主应用再次加载子应用,就提示:

died in status LOADING_SOURCE_CODE: Failed to fetch


这是因为Nginx没有配置跨域请求,只要做如下配置,重启nginx,再次加载子应用就没问题了:

location / {  
    add_header Access-Control-Allow-Origin *;
    add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
    add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
    if ($request_method = 'OPTIONS') {
        return 204;
    }
}


关于nginx跨域,详见:Nginx配置跨域请求 Access-Control-Allow-Origin *