I want to add a line that will point to a different database depending on the server I am running node.js on (localhost vs test.com, etc). How do I get the server name in node.js? That is, what is the server side equivalent to location.host?
var os = require('os');
os.hostname();
link
req.headers.host #The request host.
You can refer to Node.js document here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With