From 086183b5636aa8d075d01fe59492c3eab0d1345b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C4=81rti=C5=86=C5=A1=20Mo=C5=BEeiko?= Date: Thu, 17 Dec 2020 18:11:20 -0800 Subject: [PATCH] feat: allow to listen server on specific host interface (#381) fix #273 --- server/index.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/server/index.ts b/server/index.ts index 657c2bfeb..ef7cd56e0 100644 --- a/server/index.ts +++ b/server/index.ts @@ -101,11 +101,20 @@ app ); const port = Number(process.env.PORT) || 3000; - server.listen(port, () => { - logger.info(`Server ready on port ${port}`, { - label: 'Server', + const host = process.env.HOST; + if (host) { + server.listen(port, host, () => { + logger.info(`Server ready on ${host} port ${port}`, { + label: 'Server', + }); }); - }); + } else { + server.listen(port, () => { + logger.info(`Server ready on port ${port}`, { + label: 'Server', + }); + }); + } }) .catch((err) => { logger.error(err.stack);