简体   繁体   中英

How to open a react CRA from another computer connected to the same network?

i have been trying to open Create react app preview on my phone ( android oneplus 7pro ) using the network ip address provided in the terminal for ex. http://192.168.100.3:3000 if i visit the link it says unreachable.

  • i have tried adding the the phone ip address in the host file
  • also tried HOST=0.0.0.0 npm run start

firewall is also disabled

details: Macbook Pro 2018

Having a HOST env variable shouldn't cause a problem, but in case it did, you can always try to use "serve" after you build your project

npm run build
serve -s build -l 3000

but make sure that you install the "serve" package, this works for me, but you lose the hot reloading functionality as you have to rebuild each time.

If this doesn't work for you, probably a network issue, try to ping the computer you trying to reach.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM