Reputation: 91
I have two servers :
How can I check which server is my code running at?
I want to do a backup of my data from the production one but not from the dev one. Any ideas on how to do that?
Upvotes: 3
Views: 1184
Reputation: 318172
You can get the hostname in any request
app.get('/', function(req, res) {
var domain = req.headers.host;
var parts = domain.split(".");
//assume www for no subdomain
var subdomain = parts.length == 2 ? "www" : parts[0];
....
});
Upvotes: 2