本地网络上的其他人如何在我的机器上运行时访问我的 NodeJS 应用程序? [英] How could others, on a local network, access my NodeJS app while it's running on my machine?

查看:18
本文介绍了本地网络上的其他人如何在我的机器上运行时访问我的 NodeJS 应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常直接的问题.我用NodeJS做了一个网页游戏,可以自己玩多个浏览器窗口并排打开成功;但是,我想知道其他本地计算机是否也可以访问并与我一起玩游戏.

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, I'd like to know if it's possible for other local machines to be able to access and play the game with me too.

我天真地尝试使用这个网址:my-ip-address:8000 但它不起作用.

I naively tried using this url: my-ip-address:8000 and it won't work.

推荐答案

您的 node.js 服务器通常在脚本末尾确定的端口上运行.有时 3000.但可以是任何东西.别人访问的正确方式如你所说...

Your node.js server is running on a port determined at the end of the script usually. Sometimes 3000. but can be anything. The correct way for others to access is as you say...

http://your.network.ip.address:port/

例如

http://192.168.0.3:3000

检查您的端口是否正确 - 以及网络上的 IP 地址 - 而不是互联网 IP.

Check you have the correct port - and the IP address on the network - not the internet IP.

否则,可能是您的路由器阻止了端口.尝试使用 8080 或 80 来解决此问题 - 否则请重新配置您的路由器.

Otherwise, maybe the ports are being blocked by your router. Try using 8080 or 80 to get around this - otherwise re-configure your router.

这篇关于本地网络上的其他人如何在我的机器上运行时访问我的 NodeJS 应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆