diff --git a/src/lib/pg/download.ts b/src/lib/pg/download.ts index 0babc13c08..91652b0fba 100644 --- a/src/lib/pg/download.ts +++ b/src/lib/pg/download.ts @@ -1,5 +1,6 @@ import cliProgress from 'cli-progress' import fs from 'fs-extra' +import {HttpsProxyAgent} from 'https-proxy-agent' import https from 'node:https' import Path from 'node:path' @@ -30,7 +31,9 @@ export default function download(url: string, path: string, opts: downloadOption return new Promise((resolve, reject) => { fs.mkdirSync(Path.dirname(path), {recursive: true}) const file = fs.createWriteStream(path) - https.get(url, (rsp: any) => { + const proxy = process.env.https_proxy || process.env.HTTPS_PROXY + const options: https.RequestOptions = proxy ? {agent: new HttpsProxyAgent(proxy)} : {} + https.get(url, options, (rsp: any) => { if (tty && opts.progress) showProgress(rsp) rsp.pipe(file) .on('error', reject)