From bddd64d5b7eba65e1b0f0ec36fd8af2e7d5e3ce6 Mon Sep 17 00:00:00 2001 From: BackRunner Date: Mon, 4 Jul 2022 20:53:02 +0800 Subject: [PATCH] fix: optimize the judgment on whether HTTPS has been set in options (#7202) --- packages/@vue/cli-service/lib/commands/serve.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/@vue/cli-service/lib/commands/serve.js b/packages/@vue/cli-service/lib/commands/serve.js index cc66855e8b..c4fad51798 100644 --- a/packages/@vue/cli-service/lib/commands/serve.js +++ b/packages/@vue/cli-service/lib/commands/serve.js @@ -101,7 +101,11 @@ module.exports = (api, options) => { } // resolve server options - const useHttps = args.https || projectDevServerOptions.https || defaults.https + const modesUseHttps = ['https', 'http2'] + const serversUseHttps = ['https', 'spdy'] + const optionsUseHttps = modesUseHttps.some(modeName => !!projectDevServerOptions[modeName]) || + (typeof projectDevServerOptions.server === 'string' && serversUseHttps.includes(projectDevServerOptions.server)) + const useHttps = args.https || optionsUseHttps || defaults.https const protocol = useHttps ? 'https' : 'http' const host = args.host || process.env.HOST || projectDevServerOptions.host || defaults.host portfinder.basePort = args.port || process.env.PORT || projectDevServerOptions.port || defaults.port