简体   繁体   English

如何设置工作网络上其他人可以使用node.js访问的服务器?

[英]How to set up a server that others on my work network can access using node.js?

I'm very new to node.js, I've created a server two ways. 我对node.js很陌生,我用两种方法创建了服务器。

One way like this: 这样的一种方式:

server.js: server.js:

var connect = require("connect");
var serveStatic = require("serve-static");
connect().use(serveStatic(__dirname)).listen(8080);

node.js cmd line: node.js cmd行:

H:\> npm install connect serve-static
H:\> node server.js

And the other way like this 像这样

H:\> npm install http-server -g
http-server "C:\directory"

But these just create servers on my computer at http://localhost:8080 . 但是这些只是在我的计算机上的http://localhost:8080上创建服务器。 How can I adjust this code to make the server accessible for other people on my work network? 如何调整此代码,使工作网络中的其他人可以访问服务器?

Thanks in advance. 提前致谢。

The server is accessible from your network already. 该服务器已经可以从您的网络访问。 Just use your IP address or real hostname. 只需使用您的IP地址或真实主机名即可。

http://203.0.113.1:8080/

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

相关问题 如何让我的网络上的其他人可以访问node.js服务器? - How can I make a node.js server accessible to others on my network? Node.js - 如何在我的本地计算机上设置服务器并允许某人访问它(用于测试) - Node.js - How to set up a server on my local machine and allow someone to access it(for testing) 如何在EC2环境中使用node-mongodb-native在Node.js服务器上设置MongoDB? - How can I set up MongoDB on a Node.js server using node-mongodb-native in an EC2 environment? 如何在Node.js中设置和访问类属性? - How to set up and access class properties in Node.js? 在远程服务器上运行 node.js/express 应用程序供其他人访问? - Running a node.js/express app on a remote server for others to access? 我可以允许特定设备访问node.js服务器并阻止所有其他设备吗? - Can i allow specific device to access node.js server and block all the others? 如何通过互联网访问我的Express Node.js服务器? - How can I access my Express Node.js server through the internet? 如何故意使我的node.js服务器崩溃? - How can I purposefully crash my node.js server? 其他人正在访问我的node.js吗? - Accessing my node.js by others? 如何在我的Nginx服务器上设置两个节点JS应用程序 - How to set up two node JS applications on my nginx server
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM