Skip to content

Commit

Permalink
fix(cli): log correct hostname (#5156)
Browse files Browse the repository at this point in the history
  • Loading branch information
dominikg committed Sep 30, 2021
1 parent c1ce471 commit 6f977a5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
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

0 comments on commit 6f977a5

Please sign in to comment.