Skip to content

Commit

Permalink
fix: https error
Browse files Browse the repository at this point in the history
  • Loading branch information
ikechan8370 committed Dec 12, 2023
1 parent ca34338 commit d00ab5d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions utils/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`)
}
Expand Down

0 comments on commit d00ab5d

Please sign in to comment.