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

相關文章
相關標籤/搜索