diff --git a/packages/nuxi/src/commands/dev.ts b/packages/nuxi/src/commands/dev.ts index 57abb5793ff..4fa81e740ce 100644 --- a/packages/nuxi/src/commands/dev.ts +++ b/packages/nuxi/src/commands/dev.ts @@ -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) diff --git a/packages/vite/src/vite-node.ts b/packages/vite/src/vite-node.ts index d85f5968094..699255b2a01 100644 --- a/packages/vite/src/vite-node.ts +++ b/packages/vite/src/vite-node.ts @@ -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'