websocket.js?a9be:46 WebSocket connection to 'ws://domain/_next/webpack-hmr' failed:
quanjw opened this issue · 2 comments
quanjw commented
我在自己服务器部署了一份,项目能运行,但是浏览器打开比较慢,控制台也有这些报错。
luin commented
看报错是开发模式的 WebSocket 连接失败了。
在自己服务器部署的话要使用生产环境模式部署(NODE_ENV=production npm run build),然后把生成的内容传到服务器上。另外如果用开发模式的话,要配置服务器支持 WebSocket.
quanjw commented
关于WebSocket的问题,后面我Google了下,因为我用的Nginx反代,少了一些配置,以下是完整的。具体原因可以参考http://nginx.org/en/docs/http/websocket.html
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_pass http://127.0.0.1:3000;
}