From 15e93de99f55df70dab35d9966b220337fede128 Mon Sep 17 00:00:00 2001 From: arika Date: Mon, 4 Sep 2023 12:18:45 +0000 Subject: [PATCH] feat: add proxy support enabled proxy support for fetch by using proxy-agent. --- package.json | 1 + scripts/postinstall.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 32b98d409..2b21a6768 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "dependencies": { "bin-links": "^4.0.1", "node-fetch": "^3.2.10", + "proxy-agent": "^6.3.1", "tar": "6.1.15" }, "release": { diff --git a/scripts/postinstall.js b/scripts/postinstall.js index 8d09fddbd..4f51903fd 100644 --- a/scripts/postinstall.js +++ b/scripts/postinstall.js @@ -8,6 +8,7 @@ import binLinks from "bin-links"; import { createHash } from "crypto"; import fs from "fs"; import fetch from "node-fetch"; +import { ProxyAgent } from "proxy-agent"; import path from "path"; import tar from "tar"; import zlib from "zlib"; @@ -71,7 +72,7 @@ const fetchAndParseCheckSumFile = async (packageJson) => { // Fetch the checksum file console.info("Downloading", checksumFileUrl); - const response = await fetch(checksumFileUrl); + const response = await fetch(checksumFileUrl, {agent: new ProxyAgent()}); if (response.ok) { const checkSumContent = await response.text(); const lines = checkSumContent.split("\n");