diff --git a/packages/nuxi/package.json b/packages/nuxi/package.json index f36ee8775d..cab00f66f7 100644 --- a/packages/nuxi/package.json +++ b/packages/nuxi/package.json @@ -36,7 +36,7 @@ "flat": "^5.0.2", "giget": "^0.1.7", "jiti": "^1.16.0", - "listhen": "^0.3.1", + "listhen": "^0.3.4", "mlly": "^0.5.16", "mri": "^1.2.0", "pathe": "^0.3.8", diff --git a/packages/nuxi/src/commands/dev.ts b/packages/nuxi/src/commands/dev.ts index d4b6a83604..826a07e829 100644 --- a/packages/nuxi/src/commands/dev.ts +++ b/packages/nuxi/src/commands/dev.ts @@ -94,7 +94,7 @@ export default defineNuxtCommand({ currentNuxt.options.server.url = listener.url currentNuxt.options.server.port = address.port currentNuxt.options.server.host = address.address - currentNuxt.options.server.https = Boolean(args.https) + currentNuxt.options.server.https = listener.https await Promise.all([ writeTypes(currentNuxt).catch(console.error), diff --git a/packages/schema/src/config/server.ts b/packages/schema/src/config/server.ts index 0c16247735..bbcb69a59d 100644 --- a/packages/schema/src/config/server.ts +++ b/packages/schema/src/config/server.ts @@ -20,6 +20,8 @@ export default { * * @version 2 * + * @type {false | { key: string; cert: string }} + * * @deprecated This option is ignored with Bridge and Nuxt 3 */ https: false, diff --git a/packages/vite/src/client.ts b/packages/vite/src/client.ts index 1615a9a03b..9f7df783b4 100644 --- a/packages/vite/src/client.ts +++ b/packages/vite/src/client.ts @@ -2,7 +2,7 @@ import { join, resolve } from 'pathe' import * as vite from 'vite' import vuePlugin from '@vitejs/plugin-vue' import viteJsxPlugin from '@vitejs/plugin-vue-jsx' -import type { Connect, HmrOptions } from 'vite' +import type { Connect, ServerOptions } from 'vite' import { logger } from '@nuxt/kit' import { getPort } from 'get-port-please' import { joinURL, withLeadingSlash, withoutLeadingSlash, withTrailingSlash } from 'ufo' @@ -89,10 +89,12 @@ export async function buildClient (ctx: ViteBuildContext) { port: hmrPortDefault, ports: Array.from({ length: 20 }, (_, i) => hmrPortDefault + 1 + i) }) - clientConfig.server.hmr = defu(clientConfig.server.hmr as HmrOptions, { - // https://github.com/nuxt/framework/issues/4191 - protocol: 'ws', - port: hmrPort + clientConfig.server = defu(clientConfig.server, { + https: ctx.nuxt.options.server.https, + hmr: { + protocol: ctx.nuxt.options.server.https ? 'wss' : 'ws', + port: hmrPort + } }) } diff --git a/yarn.lock b/yarn.lock index 5558e0052e..abc89e4004 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9100,9 +9100,9 @@ __metadata: languageName: node linkType: hard -"listhen@npm:^0.3.1": - version: 0.3.1 - resolution: "listhen@npm:0.3.1" +"listhen@npm:^0.3.4": + version: 0.3.4 + resolution: "listhen@npm:0.3.4" dependencies: clipboardy: ^3.0.0 colorette: ^2.0.19 @@ -9112,7 +9112,7 @@ __metadata: ip-regex: ^5.0.0 node-forge: ^1.3.1 ufo: ^0.8.5 - checksum: 2a260fd6edbf8459be04e6f762617b535a3bbbf92d79e219145c3a301b141b93987a2cfee42081a929e9d92b3628dc2cec93cb1fea4ec0539914c5dc3331fca2 + checksum: 36068cd386ba09aaf94280a983cc2e48510e876b307318b1f21af14f85d389297a139caea2d1cc3513641d80c4acc7f7234b941de7db42c2be22690f82200cd4 languageName: node linkType: hard @@ -10478,7 +10478,7 @@ __metadata: fsevents: ~2.3.2 giget: ^0.1.7 jiti: ^1.16.0 - listhen: ^0.3.1 + listhen: ^0.3.4 mlly: ^0.5.16 mri: ^1.2.0 pathe: ^0.3.8