1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

🚀 Vite + Docker で localhost:5173 が開かない問題に遭遇した話

1
Posted at

経緯

Docker環境でReactプロジェクトを初めて起動した際に、
http://localhost:5173 をアクセスしたら開けない問題が発生しました。

原因

原因としては、
Docker環境でプロジェクトを構築していたため、
localhostがコンテナ内を指しており、ホスト側(自分のPC)からアクセスできないことでした。

改善

npm run dev の末尾に -- --host のオプションをつけることで解決しました。

$ npm run dev -- --host

このオプションを付与することで、
ホスト側(自分のPCにある全てのアプリ)からアクセスすることが可能になります。

最後に

まだまだ、ネットワークの疎通に関しては、知識があやふやで、説明がわかりにくいので、知識がより固まり次第この記事を更新したいと思います。

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?