From cf0fe6d67ce27853f1aaea2b2224bd6d0f0a449f Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Mon, 11 Sep 2023 14:21:29 +0200 Subject: [PATCH] fix: allow overriding internal dev server error via `_PORT` (#165) --- src/commands/dev-child.ts | 1 + src/utils/dev.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/commands/dev-child.ts b/src/commands/dev-child.ts index fb6b2b68..47ba7a6d 100644 --- a/src/commands/dev-child.ts +++ b/src/commands/dev-child.ts @@ -48,6 +48,7 @@ export default defineCommand({ clear: !!ctx.args.clear, dotenv: !!ctx.args.dotenv, https: devProxyOptions.https, + port: process.env._PORT ?? undefined, }) // IPC Hooks diff --git a/src/utils/dev.ts b/src/utils/dev.ts index ce172dc5..c8c59d64 100644 --- a/src/utils/dev.ts +++ b/src/utils/dev.ts @@ -24,13 +24,14 @@ export interface NuxtDevServerOptions { clear: boolean overrides: NuxtConfig https?: boolean | HTTPSOptions + port?: string | number loadingTemplate?: ({ loading }: { loading: string }) => string } export async function createNuxtDevServer(options: NuxtDevServerOptions) { const devServer = new NuxtDevServer(options) devServer.listener = await listen(devServer.handler, { - port: 0, + port: options.port ?? 0, hostname: '127.0.0.1', showURL: false, })