api/env: update proxy envs when changed in env file

This commit is contained in:
jj
2025-07-19 16:04:21 +00:00
parent 3c5f5b90b2
commit 00b2a8f085
3 changed files with 30 additions and 4 deletions

View File

@@ -337,10 +337,15 @@ export const runAPI = async (express, app, __dirname, isPrimary = true) => {
randomizeCiphers();
setInterval(randomizeCiphers, 1000 * 60 * 30); // shuffle ciphers every 30 minutes
env.subscribe('externalProxy', () => {
env.subscribe(['externalProxy', 'httpProxyValues'], () => {
// TODO: remove env.externalProxy in a future version
const options = {};
if (env.externalProxy) {
options.httpProxy = env.externalProxy;
}
setGlobalDispatcher(
new EnvHttpProxyAgent({ httpProxy: env.externalProxy || undefined })
new EnvHttpProxyAgent(options)
);
});