@@ -10,6 +10,10 @@ import { Green, Yellow } from "../misc/console-text.js";
1010const forceLocalProcessingOptions = [ "never" , "session" , "always" ] ;
1111const youtubeHlsOptions = [ "never" , "key" , "always" ] ;
1212
13+ const httpProxyVariables = [ "NO_PROXY" , "HTTP_PROXY" , "HTTPS_PROXY" ] . flatMap (
14+ k => [ k , k . toLowerCase ( ) ]
15+ ) ;
16+ 1317const changeCallbacks = { } ;
1418
1519const onEnvChanged = ( changes ) => {
@@ -43,6 +47,18 @@ export const loadEnvs = (env = process.env) => {
4347 }
4448 } ) ) ;
4549
50+ // we need to copy the proxy envs (HTTP_PROXY, HTTPS_PROXY)
51+ // back into process.env, so that EnvHttpProxyAgent can pick
52+ // them up later
53+ for ( const key of httpProxyVariables ) {
54+ const value = env [ key ] ?? canonicalEnv [ key ] ;
55+ if ( value !== undefined ) {
56+ process . env [ key ] = env [ key ] ;
57+ } else {
58+ delete process . env [ key ] ;
59+ }
60+ }
61+ 4662 return {
4763 apiURL : env . API_URL || '' ,
4864 apiPort : env . API_PORT || 9000 ,
@@ -79,6 +95,9 @@ export const loadEnvs = (env = process.env) => {
7995
8096 externalProxy : env . API_EXTERNAL_PROXY ,
8197
98+ // used only for comparing against old values when envs are being updated
99+ httpProxyValues : httpProxyVariables . map ( k => String ( env [ k ] ) ) . join ( '' ) ,
100+ 82101 turnstileSitekey : env . TURNSTILE_SITEKEY ,
83102 turnstileSecret : env . TURNSTILE_SECRET ,
84103 jwtSecret : env . JWT_SECRET ,
@@ -202,7 +221,8 @@ const wrapReload = (contents) => {
202221 for ( const key of changes ) {
203222 const value = currentEnv [ key ] ;
204223 const isSecret = key . toLowerCase ( ) . includes ( 'apikey' )
205- || key . toLowerCase ( ) . includes ( 'secret' ) ;
224+ || key . toLowerCase ( ) . includes ( 'secret' )
225+ || key === 'httpProxyValues' ;
206226
207227 if ( ! value ) {
208228 console . log ( ` removed: ${ key } ` ) ;
0 commit comments