Support HOMEPAGE_PROXY_DISABLE_IPV6

This commit is contained in:
shamoon
2025-02-27 16:52:00 -08:00
parent b5ac617597
commit 4df2ca25a4
2 changed files with 15 additions and 5 deletions

View File

@@ -83,18 +83,18 @@ export function httpRequest(url, params) {
export async function httpProxy(url, params = {}) {
const constructedUrl = new URL(url);
const disableIpv6 = process.env.HOMEPAGE_PROXY_DISABLE_IPV6 === "true";
const agentOptions = disableIpv6 ? { family: 4, autoSelectFamily: false } : {};
let request = null;
if (constructedUrl.protocol === "https:") {
request = httpsRequest(constructedUrl, {
agent: new https.Agent({
rejectUnauthorized: false,
}),
agent: new https.Agent({ ...agentOptions, rejectUnauthorized: false }),
...params,
});
} else {
request = httpRequest(constructedUrl, {
agent: new http.Agent(),
agent: new http.Agent(agentOptions),
...params,
});
}