How to open a create-react-app from another computer connected to the same network?

前端 未结 10 557
旧时难觅i
旧时难觅i 2021-02-02 06:38

I am using create-react-app and hosting in its default port localhost:3000 and want to access this from another device on the same net

相关标签:
10条回答
  • 2021-02-02 07:01

    After running npm start go to your terminal "bash, cmd ..etc" and run ipconfig

    IPv4-Adresse ..... : for example 111.222.333.444

    open browser in your second device and type : 111.222.333.444:portNumber

    0 讨论(0)
  • 2021-02-02 07:02

    Can you please turn off your firewall and check 192.168.0.5:3000.

    Thanks

    0 讨论(0)
  • 2021-02-02 07:03

    Sometimes there is another problem for Windows users.

    Windows Firewall blocks NodeJs.

    Just go to Windows Defender Firewall and click to Allow an app or feature through Windows Defender Firewall and allow Node.js

    0 讨论(0)
  • 2021-02-02 07:05

    if you have two machines (lets say pc1 and pc2) and both are connected over the same wifi connection, then:

    • bind your create-react-app development server to your Wireless LAN adapter wi-fi IPv4 address (on windows type the command ipconfig.exe and unix-like systems type ifconfig).. you will find the ip address under something:
    • Wireless LAN adapter Wi-Fi (on windows)
    • wlp5s0 inet Ip_Address
    • in your sheel where you develop react run HOST=your_IP npm run start

    now, your development machin will be the server that serves the ui over it's IP_Address

    0 讨论(0)
  • 2021-02-02 07:09

    In my case, npm run start used my Ethernet adapter's IP e.g. http://192.168.167.113:3000 but as I was accessing the site using WLAN, I needed to use WLAN IP which was 192.168.0.227.

    Make sure to use WLAN IP with the same port to make it work.

    0 讨论(0)
  • 2021-02-02 07:16

    As I can't post comment, In complementary to Elad if you have react-scripts start instead of npm run start

    HOST=0.0.0.0 react-scripts start

    Works too !

    0 讨论(0)
提交回复
热议问题