From 4623170c996213cf94008a3dd51ddaa9c9ebadf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Sun, 11 Jun 2017 15:49:01 +0200 Subject: [PATCH] Display localhost instead of 0.0.0.0 --- lib/server.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/lib/server.js b/lib/server.js index 22a08dafc1..a6f10a300b 100644 --- a/lib/server.js +++ b/lib/server.js @@ -11,14 +11,14 @@ class Server { this.app = connect() this.server = http.createServer(this.app) this.nuxt.ready() - .then(() => { - // Add Middleware - this.options.serverMiddleware.forEach(m => { - this.useMiddleware(m) - }) - // Add default render middleware - this.useMiddleware(this.render.bind(this)) + .then(() => { + // Add Middleware + this.nuxt.options.serverMiddleware.forEach(m => { + this.useMiddleware(m) }) + // Add default render middleware + this.useMiddleware(this.render.bind(this)) + }) return this } @@ -46,9 +46,15 @@ class Server { } listen (port, host) { - host = host || '127.0.0.1' + host = host || 'localhost' port = port || 3000 this.nuxt.ready() + .then(() => { + this.server.listen(port, host, () => { + let _host = host === '0.0.0.0' ? 'localhost' : host + console.log('Ready on http://%s:%s', _host, port) // eslint-disable-line no-console + }) + }) .then(() => { this.server.listen(port, host, () => { console.log('Ready on http://%s:%s', host, port) // eslint-disable-line no-console