best way to save what you love
Svelte collaborationdownloaderinstagramjavascriptmusicredditsocial-mediasoundcloudsveltetiktoktwittertypescriptvideovimeovkwebappyoutubeyoutube-downloader
api/core: use EnvHttpProxyAgent for proxy requests
wukkoe83baa913883
diff --git a/api/src/core/api.js b/api/src/core/api.jsindex 248f9357..27ea9a06 100644--- a/api/src/core/api.js+++ b/api/src/core/api.js@@ -1,7 +1,7 @@import cors from "cors";import http from "node:http";import rateLimit from "express-rate-limit";-import { setGlobalDispatcher, ProxyAgent } from "undici";+import { setGlobalDispatcher, EnvHttpProxyAgent } from "undici";import { getCommit, getBranch, getRemote, getVersion } from "@imput/version-info";import jwt from "../security/jwt.js";@@ -337,9 +337,10 @@ export const runAPI = async (express, app, __dirname, isPrimary = true) => {randomizeCiphers();setInterval(randomizeCiphers, 1000 * 60 * 30); // shuffle ciphers every 30 minutes- if (env.externalProxy) {- setGlobalDispatcher(new ProxyAgent(env.externalProxy))- }+ // TODO: remove env.externalProxy in a future version+ setGlobalDispatcher(+ new EnvHttpProxyAgent({ httpProxy: env.externalProxy || undefined })+ );http.createServer(app).listen({port: env.apiPort,diff --git a/api/src/util/test.js b/api/src/util/test.jsindex abb9b3cd..98a9f131 100644--- a/api/src/util/test.js+++ b/api/src/util/test.js@@ -4,7 +4,7 @@ import { env } from "../config.js";import { runTest } from "../misc/run-test.js";import { loadJSON } from "../misc/load-from-fs.js";import { Red, Bright } from "../misc/console-text.js";-import { setGlobalDispatcher, ProxyAgent } from "undici";+import { setGlobalDispatcher, EnvHttpProxyAgent, ProxyAgent } from "undici";import { randomizeCiphers } from "../misc/randomize-ciphers.js";import { services } from "../processing/service-config.js";@@ -69,9 +69,10 @@ const printHeader = (service, padLen) => {console.log(service + '='.repeat(50));}-if (env.externalProxy) {- setGlobalDispatcher(new ProxyAgent(env.externalProxy));-}+// TODO: remove env.externalProxy in a future version+setGlobalDispatcher(+ new EnvHttpProxyAgent({ httpProxy: env.externalProxy || undefined })+);env.streamLifespan = 10000;env.apiURL = 'http://x/';diff --git a/docs/api-env-variables.md b/docs/api-env-variables.mdindex 5a836bfa..f01f22ba 100644--- a/docs/api-env-variables.md+++ b/docs/api-env-variables.md@@ -124,7 +124,7 @@ defines the local address for the api instance. if you are using a docker contaithe value is a local IP address.### API_EXTERNAL_PROXY-URL of the proxy that will be passed to [`ProxyAgent`](https://undici.nodejs.org/#/docs/api/ProxyAgent) and used for all external requests. HTTP(S) only.+URL of the proxy that will be passed to [`EnvHttpProxyAgent`](https://undici.nodejs.org/#/docs/api/EnvHttpProxyAgent) and used for all external requests. HTTP(S) only.if some feature breaks when using a proxy, please make a new issue about it!