如何将我的节点表达应用程序仅限制为localhost?

时间:2021-07-12 07:25:12

I have a node express application that I want to only be available to the localhost client. How can I prevent other hosts from accessing my node express app?

我有一个节点快速应用程序,我想只对localhost客户端可用。如何防止其他主机访问我的节点快递应用?

1 个解决方案

#1


2  

When you start listening your server just mentioned the host name as 'localhost'. Take a look at the following code.

当您开始监听服务器时,刚才提到主机名为“localhost”。看看下面的代码。

var app = require('express')();
app.listen(8000,'localhost');

#1


2  

When you start listening your server just mentioned the host name as 'localhost'. Take a look at the following code.

当您开始监听服务器时,刚才提到主机名为“localhost”。看看下面的代码。

var app = require('express')();
app.listen(8000,'localhost');