最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Cant view React app on lan from another pc - Stack Overflow

programmeradmin2浏览0评论

I just created a new react app using create-react-app. when I tried access the app from another pc on the same lan, it seems to be loading but doesn't shows up.
I am able to view the static files with no problem.
Thanks for your help.

Update: Tried on other lan network and it's working! what can be the reason it doesn't work on the first lan?

I just created a new react app using create-react-app. when I tried access the app from another pc on the same lan, it seems to be loading but doesn't shows up.
I am able to view the static files with no problem.
Thanks for your help.

Update: Tried on other lan network and it's working! what can be the reason it doesn't work on the first lan?

Share Improve this question edited Mar 1, 2019 at 11:33 Zohar Golan asked Mar 1, 2019 at 8:57 Zohar GolanZohar Golan 511 gold badge1 silver badge7 bronze badges 2
  • Inspect network and console to provide more insights into your problem. – Apolo Commented Mar 1, 2019 at 9:12
  • It seems that the browser is pending for the bundle.js nothing on console... – Zohar Golan Commented Mar 1, 2019 at 9:15
Add a ment  | 

3 Answers 3

Reset to default 1

See the Create-React-App docs:

HOST:
By default, the development web server binds to localhost. You may use this variable to specify a different host.

Set the HOST environment variable (in .env or in your shell) to 0.0.0.0 to bind to every address and you should be off to the races.

You have to make sure that the port 3000 is open on your machine (or any other that you use).

In addition, you can try to serve application on 0.0.0.0 host instead of localhost.

To access your localhost react dev server on another puter on the same LAN you need to know the LAN IP of the host puter where the react dev server is running. On mac you can find the ip here: System Preferences > Network > Advanced > TCP/IP. It is either the IPv4 or IPv6 address.

Just replace localhost with the IP address when accessing the server with the other puter.

For example: localhost:3000 > 192.168.1.179:3000

发布评论

评论列表(0)

  1. 暂无评论