How could others, on a local network, access my NodeJS app while it's running on my machine?

后端 未结 15 1667
旧时难觅i
旧时难觅i 2020-12-02 07:55

I have a pretty straight-forward question. I made a web game with NodeJS, and I can successfully play it by myself with multiple browser windows open side-by-side; however,

15条回答
  •  南方客
    南方客 (楼主)
    2020-12-02 08:00

    One tip that nobody has mentioned yet is to remember to host the app on the LAN-accessible address 0.0.0.0 instead of the default localhost. Firewalls on Mac and Linux are less strict about this address compared to the default localhost address (172.0.0.1).

    For example,

    gatsby develop --host 0.0.0.0

    yarn start --host 0.0.0.0

    npm start --host 0.0.0.0

    You can then access the address to connect to by entering ifconfig or ipconfig in the terminal. Then try one of the IP addresses on the left that does not end in .255 or .0

提交回复
热议问题