api/core: use EnvHttpProxyAgent for proxy requests
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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/';
|
||||
|
||||
Reference in New Issue
Block a user