Answers for "node check if running on localhost?"

0

node check if running on localhost?

var os = require('os');
var database_uri;

if(os.hostname().indexOf("local") > -1)
  // Server running on Localhost
  database_uri = "mongodb://localhost/database";
else
  // Server running on remote server
  database_uri = "mongodb://remotehost/database";
Posted by: Guest on October-21-2020

Code answers related to "node check if running on localhost?"

Code answers related to "Javascript"

Browse Popular Code Answers by Language