From 019e623c21d380e10ac78cd88514480b92ff7be3 Mon Sep 17 00:00:00 2001 From: cel Date: Sun, 30 Jul 2017 12:28:34 -1000 Subject: Let nodejs decide what localhost is --- lib/app.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/app.js b/lib/app.js index d2a029b..b122f1d 100644 --- a/lib/app.js +++ b/lib/app.js @@ -21,7 +21,7 @@ function App(sbot, config) { var conf = config.patchfoo || {} this.port = conf.port || 8027 - this.host = conf.host || '::1' + this.host = conf.host || 'localhost' var base = conf.base || '/' this.opts = { @@ -48,12 +48,15 @@ function App(sbot, config) { App.prototype.go = function () { var self = this - http.createServer(function (req, res) { + var server = http.createServer(function (req, res) { new Serve(self, req, res).go() - }).listen(self.port, self.host, function () { + }) + if (self.host === 'localhost') server.listen(self.port, onListening) + else server.listen(self.port, self.host, onListening) + function onListening() { var host = /:/.test(self.host) ? '[' + self.host + ']' : self.host self.log('Listening on http://' + host + ':' + self.port) - }) + } // invalidate cached About info when new About messages come in pull( -- cgit v1.2.3