From d00ab5df5f5d500c6d0c85eba014ad4690a00da9 Mon Sep 17 00:00:00 2001 From: ikechan8370 Date: Tue, 12 Dec 2023 20:12:30 +0800 Subject: [PATCH] fix: https error --- utils/common.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/utils/common.js b/utils/common.js index ab27aa5..cfe04f3 100644 --- a/utils/common.js +++ b/utils/common.js @@ -1039,11 +1039,13 @@ export function getUserSpeaker (userSetting) { * @returns {Promise} 最终下载文件的存储位置 */ export async function downloadFile (url, destPath, absolute = false, ignoreCertificateError = true) { - let response = await fetch(url, { - agent: new https.Agent({ + let init = {} + if (ignoreCertificateError && url.startsWith('https')) { + init.agent = new https.Agent({ rejectUnauthorized: !ignoreCertificateError }) - }) + } + let response = await fetch(url, init) if (!response.ok) { throw new Error(`download file http error: status: ${response.status}`) }