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?
Asked
Active
Viewed 7,194 times
6
-
1possible duplicate of [How to get Node.JS Express to listen only on localhost?](http://stackoverflow.com/questions/10068714/how-to-get-node-js-express-to-listen-only-on-localhost) – ashfaq.p Nov 11 '14 at 12:32
-
1seems to be a different problem and solution. – srayner Nov 11 '14 at 12:49
1 Answers
11
When you start listening your server just mentioned the host name as 'localhost'. Take a look at the following code.
var app = require('express')();
app.listen(8000,'localhost');

Asis Datta
- 561
- 3
- 11