Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

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

Merged
merged 2 commits into from
Sep 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/nuxi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxi/src/commands/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions packages/schema/src/config/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 7 additions & 5 deletions packages/vite/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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
}
})
}

Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down