fix: https error

This commit is contained in:
ikechan8370 2023-12-12 20:12:30 +08:00
parent ca34338b72
commit d00ab5df5f

View file

@ -1039,11 +1039,13 @@ export function getUserSpeaker (userSetting) {
* @returns {Promise<string>} 最终下载文件的存储位置
*/
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}`)
}