6

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?

srayner
  • 1,799
  • 4
  • 23
  • 39
  • 1
    possible 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
  • 1
    seems to be a different problem and solution. – srayner Nov 11 '14 at 12:49

1 Answers1

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