-1

Working on node app and want to make the contents of a page only available when on localhost. What is the best way/best practices to accomplish this?

f00
  • 13
  • 1
  • 9

2 Answers2

1

put local ip restriction (eg 127.0.0.1)

refer to this stackoverflow link for more info on how to do it

Restrict access to Node.js-based HTTP server by IP address

Community
  • 1
  • 1
erwan
  • 887
  • 8
  • 17
1

If you are using Express, you can use this:

var express = require('express');
var app = express();
...
app.listen(3000, '127.0.0.1');

You can find more detailed explanation about this feature here: http://expressjs.com/en/api.html#app.listen

You can also achieve this with adding a rule in your firewall that will allow only connections from localhost.