Skip to content

best way to save what you love

api/core: update dispatcher when proxy is changed

jj09c42d9be024
diff --git a/api/src/core/api.js b/api/src/core/api.js
index 27ea9a06..0db4d222 100644
--- a/api/src/core/api.js
+++ b/api/src/core/api.js
@@ -337,10 +337,12 @@ export const runAPI = async (express, app, __dirname, isPrimary = true) => {
randomizeCiphers();
setInterval(randomizeCiphers, 1000 * 60 * 30); // shuffle ciphers every 30 minutes
- // TODO: remove env.externalProxy in a future version
- setGlobalDispatcher(
- new EnvHttpProxyAgent({ httpProxy: env.externalProxy || undefined })
- );
+ env.subscribe('externalProxy', () => {
+ // TODO: remove env.externalProxy in a future version
+ setGlobalDispatcher(
+ new EnvHttpProxyAgent({ httpProxy: env.externalProxy || undefined })
+ );
+ });
http.createServer(app).listen({
port: env.apiPort,