服务器每隔4-5秒就会断开连接,这会导致页面刷新,特别是在第一次呈现时,这种情况会发生多次。
控制台将显示以下消息
The development server has disconnected.
Refresh the page if necessary.这是我的webpackDevServer.config.js
module.exports = function(proxy, allowedHost) {
return {
disableHostCheck: !proxy ||
process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true',
compress: true,
clientLogLevel: 'none',
contentBase: paths.appPublic,
watchContentBase: true,
publicPath: config.output.publicPath,
quiet: true,
watchOptions: {
ignored: /node_modules/,
},
https: protocol === 'https',
host: host,
overlay: false,
historyApiFallback: {
disableDotRule: true,
},
public: allowedHost,
proxy,
setup(app) {
app.use(errorOverlayMiddleware());
app.use(noopServiceWorkerMiddleware());
},
};
}; 这是非常恼人的,要么我想停止实时重新加载,要么摆脱这个问题。
发布于 2019-12-19 01:02:49
最近,在将react-scripts更新到最新版本3.3.0后,我遇到了这个问题。我只是进入我的package.json并将"react-scripts": "3.3.0"更新为"react-scripts" : "3.2.0"
在那之后:
npm install
npm start我不再看到这个问题了。
https://stackoverflow.com/questions/54398939
复制相似问题