From cd7949f2841630e686ca2833bcb6100d8bfe7b5b Mon Sep 17 00:00:00 2001 From: Tomoya Tanaka Date: Tue, 10 Sep 2024 03:15:38 +0900 Subject: [PATCH] fix: use correct protocol when -H and --experimental-https are enabled (#69822) fixes #69820 - fixes wrong protocol issue when you run `next dev` with `--experimental-https` and `-H` option. To check the PR fixes the issue correctly, run the command below. ``` corepack pnpm next -H 0.0.0.0 --experimental-https YOUR_APP_DIRECTORY ``` Co-authored-by: JJ Kasper --- packages/next/src/server/lib/start-server.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/next/src/server/lib/start-server.ts b/packages/next/src/server/lib/start-server.ts index 28fae10c6a7fb..7f21d0a5e1477 100644 --- a/packages/next/src/server/lib/start-server.ts +++ b/packages/next/src/server/lib/start-server.ts @@ -234,7 +234,9 @@ export async function startServer( port = typeof addr === 'object' ? addr?.port || port : port - const networkUrl = hostname ? `http://${actualHostname}:${port}` : null + const networkUrl = hostname + ? `${selfSignedCertificate ? 'https' : 'http'}://${actualHostname}:${port}` + : null const appUrl = `${ selfSignedCertificate ? 'https' : 'http' }://${formattedHostname}:${port}`