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

后端 未结 15 1701
旧时难觅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:05

    This worked for me and I think this is the most basic solution which involves the least setup possible:

    1. With your PC and other device connected to the same network , open cmd from your PC which you plan to set up as a server, and hit ipconfig to get your ip address. Note this ip address. It should be something like "192.168.1.2" which is the value to the right of IPv4 Address field as shown in below format:

    Wireless LAN adapter Wi-Fi:

    Connection-specific DNS Suffix . :
    Link-local IPv6 Address . . . . . : ffff::ffff:ffff:ffff:ffad%14
    IPv4 Address. . . . . . . . . . . : 192.168.1.2
    Subnet Mask . . . . . . . . . . . : 255.255.255.0

    1. Start your node server like this : npm start e.g. npm start 192.168.1.2:3000
    2. Open browser of your other device and hit the url: i.e. 192.168.1.2:3000 and you will see your website.

提交回复
热议问题