Skip to content
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

fix(cli): log correct hostname #5156

Merged
merged 1 commit into from Sep 30, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/vite/src/node/cli.ts
Expand Up @@ -108,7 +108,7 @@ cli
}
)

printHttpServerUrls(server.httpServer, server.config, options)
printHttpServerUrls(server.httpServer, server.config)

// @ts-ignore
if (global.__vite_start_time) {
Expand Down Expand Up @@ -249,7 +249,7 @@ cli
)
const server = await preview(config, cleanOptions(options))

printHttpServerUrls(server, config, options)
printHttpServerUrls(server, config)
} catch (e) {
createLogger(options.logLevel).error(
chalk.red(`error when starting preview server:\n${e.stack}`),
Expand Down
6 changes: 2 additions & 4 deletions packages/vite/src/node/logger.ts
Expand Up @@ -6,7 +6,6 @@ import os from 'os'
import readline from 'readline'
import { RollupError } from 'rollup'
import { ResolvedConfig } from '.'
import { ServerOptions } from './server'
import { Hostname, resolveHostname } from './utils'

export type LogType = 'error' | 'warn' | 'info'
Expand Down Expand Up @@ -142,13 +141,12 @@ export function createLogger(

export function printHttpServerUrls(
server: Server,
config: ResolvedConfig,
options: ServerOptions
config: ResolvedConfig
): void {
const address = server.address()
const isAddressInfo = (x: any): x is AddressInfo => x.address
if (isAddressInfo(address)) {
const hostname = resolveHostname(options.host)
const hostname = resolveHostname(config.server.host)
const protocol = config.server.https ? 'https' : 'http'
printServerUrls(
hostname,
Expand Down