webpack-dev-server 代理服务返回的 json 内容被截断或部分乱码

缘由

Original problem spdy-http2/node-spdy#357. Unfortunately we can fix it right now, it was be fixed after express will be support http2. Now we implement http2 option in master to disable http2, you can use this as workaround

因为 webpack-dev-server 默认启用了http2, 使用的是 spdy-http2/node-spdy 库的实现, 这个 bug 是该库形成的, 并在
3.4.7版本被修复.
该问题发生在Node v8中, v10不存在此问题.node

解决

方法1

webpack.config.jswebpack

devServer: { 
    ..., 
    http2: false 
}

方法2

Node升级到v10git

参考

https://github.com/webpack/webpack-dev-server/issues/1574
https://github.com/spdy-http2/node-spdy/issues/357github

相关文章
相关标签/搜索