fix: optimize the judgment on whether HTTPS has been set in options (#7202)

This commit is contained in:
BackRunner
2022-07-04 20:53:02 +08:00
committed by GitHub
parent ef08a08c41
commit bddd64d5b7
@@ -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