I have running Node.JS & Express application on localhost (127.0.0.1) and I need to find out the current host (domain) without making requests (for cron job that starts when server is created). The server is created this way
app = express.createServer();
app.listen(PORT);
Now I've found following solution
app.address();
However the host returned by this is 0.0.0.0
, port is returned correct so I guess I need to somehow specify the host during the server start. How can I force it to get the correct host? I've tried
app = express.createServer({host: '127.0.0.1'});
but that doesn't work :(