当前位置: 代码迷 >> 综合 >> [qiankun] devScripts.js: POST xhr_streaming?t=404 (Not Found) GET eventsource net::ERR_ABORTED 404 (
  详细解决方案

[qiankun] devScripts.js: POST xhr_streaming?t=404 (Not Found) GET eventsource net::ERR_ABORTED 404 (

热度:7   发布时间:2023-12-12 01:16:36.0

enviroment

umi v3 工程作为微应用,启动主应用报错

devScripts.js:11874 POST http://localhost:8080/dev-server/633/50lodbqg/xhr_streaming?t=1606358562269 404 (Not Found)

dev-server/279/rky4ozdu/eventsource:1 GET http://localhost:8080/dev-server/279/rky4ozdu/eventsource net::ERR_ABORTED 404 (Not Found)

jsonp?c=_jp.aegwvbo:1 Uncaught SyntaxError: Unexpected token ‘<’

reason

官方文档和Google没有找到原因和相关记录
个人推测:看起来是网络不通,有点像socket层的报错,联系到vue作为微应用跨域报错问题,猜想可能是umi主页应用也需要允许跨域请求

resolution

.umi.ts中添加devServer的header头可以解决

devServer:{
    port: 8082, // 默认8000headers: {
    'Access-Control-Allow-Origin': '*','Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept'},
},
  相关解决方案