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不存在此问题.

解决

方法1

webpack.config.js

devServer: { 
    ..., 
    http2: false 
}

方法2

Node升级到v10

参考

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

你可能感兴趣的:(html5,javascript,node.js)