Added customizable host.

Use 'HOST=0.0.0.0 node app.js' to listen on all ip's.
This commit is contained in:
Bob 2019-10-23 20:05:07 +08:00
parent c0ff65b8d4
commit 9bf9ddd199

5
app.js
View File

@ -83,9 +83,10 @@ fs.readdirSync(path.join(__dirname, 'module')).reverse().forEach(file => {
})
const port = process.env.PORT || 3000
const host = process.env.HOST || 'localhost'
app.server = app.listen(port, () => {
console.log(`server running @ http://localhost:${port}`)
app.server = app.listen(port, host, () => {
console.log(`server running @ http://${host}:${port}`)
})
module.exports = app