From 68323cbd6a9de53b738be19afb81fc0f4e7c95e6 Mon Sep 17 00:00:00 2001 From: Gray Zhang Date: Tue, 22 Feb 2022 18:09:55 +0800 Subject: [PATCH] fix: don't override user config The incoming `inlineConfig` may be frozen and `Object.assign` may fail for `object is not extensible` error. --- packages/vite/src/node/http.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/vite/src/node/http.ts b/packages/vite/src/node/http.ts index f1266ddb93ba12..d58cd225226f99 100644 --- a/packages/vite/src/node/http.ts +++ b/packages/vite/src/node/http.ts @@ -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[]) {