fix(nuxi): update server.port and server.host with listener info (#6595)

This commit is contained in:
pooya parsa 2022-08-13 13:52:03 +02:00 committed by GitHub
parent 74320200e7
commit b4bea517df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -1,3 +1,4 @@
import type { AddressInfo } from 'node:net'
import { resolve, relative, normalize } from 'pathe'
import chokidar from 'chokidar'
import { debounce } from 'perfect-debounce'
@ -75,7 +76,12 @@ export default defineNuxtCommand({
}
await currentNuxt.ready()
await currentNuxt.hooks.callHook('listen', listener.server, listener)
const address = listener.server.address() as AddressInfo
currentNuxt.options.server.port = address.port
currentNuxt.options.server.host = address.address
await Promise.all([
writeTypes(currentNuxt).catch(console.error),
buildNuxt(currentNuxt)

View File

@ -135,7 +135,6 @@ export async function initViteNodeServer (ctx: ViteBuildContext) {
entryPath = resolve(ctx.nuxt.options.appDir, 'entry.async')
}
// TODO: Update me
const host = ctx.nuxt.options.server.host || 'localhost'
const port = ctx.nuxt.options.server.port || '3000'
const protocol = ctx.nuxt.options.server.https ? 'https' : 'http'