Skip to content

fix: display correct address when multiple network adapters present #4083

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/@vue/cli-service/lib/util/prepareURLs.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
const url = require('url')
const chalk = require('chalk')
const address = require('address')
const defaultGateway = require('default-gateway')

module.exports = function prepareUrls (protocol, host, port, pathname = '/') {
const formatUrl = hostname =>
Expand All @@ -33,7 +34,8 @@ module.exports = function prepareUrls (protocol, host, port, pathname = '/') {
prettyHost = 'localhost'
try {
// This can only return an IPv4 address
lanUrlForConfig = address.ip()
const result = defaultGateway.v4.sync()
lanUrlForConfig = address.ip(result && result.interface)
if (lanUrlForConfig) {
// Check if the address is a private ip
// https://en.wikipedia.org/wiki/Private_network#Private_IPv4_address_spaces
Expand Down
1 change: 1 addition & 0 deletions packages/@vue/cli-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
"cssnano": "^4.1.10",
"current-script-polyfill": "^1.0.0",
"debug": "^4.1.1",
"default-gateway": "^4.2.0",
"dotenv": "^8.0.0",
"dotenv-expand": "^5.1.0",
"file-loader": "^3.0.1",
Expand Down