Skip to content

Commit

Permalink
fix: don't override user config
Browse files Browse the repository at this point in the history
The incoming `inlineConfig` may be frozen and `Object.assign` may fail for `object is not extensible` error.
  • Loading branch information
otakustay committed Feb 22, 2022
1 parent 33f9671 commit 68323cb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/vite/src/node/http.ts
Expand Up @@ -129,16 +129,16 @@ export async function resolveHttpsConfig(
const httpsOption = isObject(https) ? https : {}

const { ca, cert, key, pfx } = httpsOption
Object.assign(httpsOption, {
const httpsOptionOut = Object.assign({}, httpsOption, {
ca: readFileIfExists(ca),
cert: readFileIfExists(cert),
key: readFileIfExists(key),
pfx: readFileIfExists(pfx)
})
if (!httpsOption.key || !httpsOption.cert) {
httpsOption.cert = httpsOption.key = await getCertificate(cacheDir)
if (!httpsOptionOut.key || !httpsOptionOut.cert) {
httpsOptionOut.cert = httpsOptionOut.key = await getCertificate(cacheDir)
}
return httpsOption
return httpsOptionOut
}

function readFileIfExists(value?: string | Buffer | any[]) {
Expand Down

0 comments on commit 68323cb

Please sign in to comment.