简体   繁体   English

如何让我的网络上的其他人可以访问node.js服务器?

[英]How can I make a node.js server accessible to others on my network?

This is a pretty straightforward question. 这是一个非常直截了当的问题。 Normally in a node app, you put http.listen('1300', '127.0.0.1); 通常在节点应用程序中,你放了http.listen('1300', '127.0.0.1); . Is there some way to do this so that other computer on my network can access the server? 有没有办法做到这一点,以便我的网络上的其他计算机可以访问服务器?

I have tried this: 我试过这个:

http.listen('1300', '192.168.0.1);

As well as this: 除此之外:

http.listen('1300', [My IP address]) 

Any help is appreciated 任何帮助表示赞赏

Problem solved by using this: 使用此问题解决了问题:

http.listen('1300');

And I access it by typing [hostname(in this case, my computers name)]:1300 into the URL bar. 我通过在URL栏中键入[hostname(in this case, my computers name)]:1300来访问它。 Hope this helps anyone who is having similar issues! 希望这可以帮助任何有类似问题的人!

From the documentation http://nodejs.org/api/http.html#http_server_listen_port_hostname_backlog_callback 来自文档http://nodejs.org/api/http.html#http_server_listen_port_hostname_backlog_callback

you should omit the host parameter. 你应该省略host参数。

the practice to add the address is just to increase security (limiting the allowed hosts to your machine) 添加地址的做法只是为了提高安全性(将允许的主机限制在您的计算机上)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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