到url/_next/webpack-hmr'的WebSocket连接失败

wrrgggsh  于 2023-08-05  发布在  Webpack
关注(0)|答案(1)|浏览(134)

我正在使用next.js版本12来部署网页,但部署时它会在控制台中给出警告
websocket.js?a9 be:45 WebSocket连接到'wss://eteaga.com/_next/webpack-hmr'失败:
在localhost中,它不会给予任何警告或问题。是新版本的next.js需要添加一些配置吗?

c86crjj0

c86crjj01#

你需要为websockets定义一个新的location block,并添加nginx配置来升级连接there

location /_next/webpack-hmr {

        # I assumed my server is running on port 3000 on localhost
        proxy_pass http://localhost:3000/_next/webpack-hmr;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

        }

字符串

相关问题