fix(nuxi, vite): support https with custom domain and hmr (#7680)

This commit is contained in:
pooya parsa 2022-09-20 12:54:52 +02:00 committed by GitHub
parent d47572e55e
commit 720da64b12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 12 deletions

View File

@ -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",

View File

@ -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),

View File

@ -20,6 +20,8 @@ export default <SchemaDefinition>{
*
* @version 2
*
* @type {false | { key: string; cert: string }}
*
* @deprecated This option is ignored with Bridge and Nuxt 3
*/
https: false,

View File

@ -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, <ServerOptions> {
https: ctx.nuxt.options.server.https,
hmr: {
protocol: ctx.nuxt.options.server.https ? 'wss' : 'ws',
port: hmrPort
}
})
}

View File

@ -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