Skip to content

feat(serve): include networkUrl in resolved promise #2682

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

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion packages/@vue/cli-service/lib/commands/serve.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ module.exports = (api, options) => {
// so other commands can do api.service.run('serve').then(...)
resolve({
server,
url: urls.localUrlForBrowser
url: urls.localUrlForBrowser,
networkUrl: urls.lanUrlForBrowser
})
} else if (process.env.VUE_CLI_TEST) {
// signal for test to check HMR
Expand Down
4 changes: 4 additions & 0 deletions packages/@vue/cli-service/lib/util/prepareURLs.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ module.exports = function prepareUrls (protocol, host, port, pathname = '/') {
const isUnspecifiedHost = host === '0.0.0.0' || host === '::'
let prettyHost, lanUrlForConfig
let lanUrlForTerminal = chalk.gray('unavailable')
let lanUrlForBrowser
if (isUnspecifiedHost) {
prettyHost = 'localhost'
try {
Expand All @@ -44,6 +45,7 @@ module.exports = function prepareUrls (protocol, host, port, pathname = '/') {
) {
// Address is private, format it for later use
lanUrlForTerminal = prettyPrintUrl(lanUrlForConfig)
lanUrlForBrowser = formatUrl(lanUrlForConfig)
} else {
// Address is not private, so we will discard it
lanUrlForConfig = undefined
Expand All @@ -56,12 +58,14 @@ module.exports = function prepareUrls (protocol, host, port, pathname = '/') {
prettyHost = host
lanUrlForConfig = host
lanUrlForTerminal = prettyPrintUrl(lanUrlForConfig)
lanUrlForBrowser = formatUrl(lanUrlForConfig)
}
const localUrlForTerminal = prettyPrintUrl(prettyHost)
const localUrlForBrowser = formatUrl(prettyHost)
return {
lanUrlForConfig,
lanUrlForTerminal,
lanUrlForBrowser,
localUrlForTerminal,
localUrlForBrowser
}
Expand Down