0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

OpenLiteSpeed + NEXT.js v12 でのWebSocketエラー解消

Last updated at Posted at 2023-05-04

はじめに

他社で開発を依頼したプログラムの移植作業で直面したエラーです。開発中はプロキシを使っていなかったものと思われますが、本番環境で動作させるときにリバースプロキシを設定してエラーが発生しました。 Next.js v12+ で発生するみたいです。解消法を備忘録も兼ねて書き留めます。

環境

  • OpenLiteSpeed でリバースプロキシを使って Next.js (localhost:3000) に接続
  • Next.js v12+

症状と対処法

症状

以下のようなエラーが出続ける...

WebSocket connection to 'ws://<DOMAIN_NAME>/_next/webpack-hmr' failed

対処法

OpenLiteSpeed の管理画面から Virtual Host → Web Socket Proxy で、 Web Socket Definition を以下のように追加するだけです。(ドメインは適宜書き換えてください)

スクリーンショット 2023-05-04 17.14.25.png

もしCyberPanelや設定ファイルで設定するとき、 vhconf.conf の記述は以下の通りになります。

websocket /_next/webpack-hmr {
  address                 localhost:3000
}
Apache/Nginx の場合(参考)

ちなみに Apache や Nginx だとリダイレクトさせて対応すると解消するようです

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?