mirror of
https://github.com/nuxt/nuxt.git
synced 2024-12-05 20:07:16 +00:00
Show all ipv4 addresses when server is running on unspecified address
This commit is contained in:
parent
9bf73b0b5a
commit
4eff3b9d27
@ -120,7 +120,28 @@ export default class Nuxt {
|
||||
|
||||
const _host = host === '0.0.0.0' ? 'localhost' : host
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('\n' + chalk.bgGreen.black(' OPEN ') + chalk.green(` http://${_host}:${port}\n`))
|
||||
console.log('\n' + chalk.bgGreen.black(' OPEN ') + chalk.green(` http://${_host}:${port}`))
|
||||
|
||||
if (host === '0.0.0.0') {
|
||||
const ifaces = require('os').networkInterfaces()
|
||||
|
||||
Object.keys(ifaces).forEach((ifName) => {
|
||||
let ifAliasNum = 0
|
||||
let ifAlias = ''
|
||||
ifaces[ifName].forEach((iface, index) => {
|
||||
if (iface.family === 'IPv4' && iface.internal === false) {
|
||||
if (ifAliasNum > 0) {
|
||||
ifAlias = `:${ifAliasNum}`
|
||||
}
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(chalk.bgGreen.black(` OPEN (${ifName}${ifAlias}) `) + chalk.green(` http://${iface.address}:${port}`))
|
||||
ifAliasNum++
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('\n')
|
||||
|
||||
// Close server on nuxt close
|
||||
this.hook('close', () => new Promise((resolve, reject) => {
|
||||
|
Loading…
Reference in New Issue
Block a user