From 8156e4057bf76281c75dae3aec6a4e86ade4378c Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Thu, 28 May 2026 17:54:52 +0200 Subject: [PATCH] Task/respect HTTP_PROXY environment variables for outbound HTTP requests (#6952) * Respect HTTP proxy environment variables for outbound HTTP requests * Update changelog --- CHANGELOG.md | 1 + apps/api/src/main.ts | 4 ++++ package-lock.json | 7 ++++--- package.json | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7817256f..d82e7dd19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` environment variable support to outbound HTTP requests - Added the `FetchService` to centralize outbound HTTP requests ### Changed diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts index f08a09a83..94e389f6a 100644 --- a/apps/api/src/main.ts +++ b/apps/api/src/main.ts @@ -18,11 +18,15 @@ import type { NestExpressApplication } from '@nestjs/platform-express'; import cookieParser from 'cookie-parser'; import { NextFunction, Request, Response } from 'express'; import helmet from 'helmet'; +import { EnvHttpProxyAgent, setGlobalDispatcher } from 'undici'; import { AppModule } from './app/app.module'; import { environment } from './environments/environment'; async function bootstrap() { + // Respect HTTP_PROXY / HTTPS_PROXY / NO_PROXY for outbound HTTP requests + setGlobalDispatcher(new EnvHttpProxyAgent()); + const configApp = await NestFactory.create(AppModule); const configService = configApp.get(ConfigService); let customLogLevels: LogLevel[]; diff --git a/package-lock.json b/package-lock.json index 7a06ea1b3..6527c6bc4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -94,6 +94,7 @@ "svgmap": "2.19.3", "tablemark": "4.1.0", "twitter-api-v2": "1.29.0", + "undici": "7.24.4", "yahoo-finance2": "3.14.2", "zone.js": "0.16.1" }, @@ -28576,9 +28577,9 @@ } }, "node_modules/jsdom/node_modules/undici": { - "version": "7.24.7", - "resolved": "https://registry.npmjs.org/undici/-/undici-7.24.7.tgz", - "integrity": "sha512-H/nlJ/h0ggGC+uRL3ovD+G0i4bqhvsDOpbDv7At5eFLlj2b41L8QliGbnl2H7SnDiYhENphh1tQFJZf+MyfLsQ==", + "version": "7.26.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-7.26.0.tgz", + "integrity": "sha512-3O9Tf67pGhgOv9jM35AbhkXAKi13f3oy3aE4CSgr+TckGeY+/iu97ZXN+J7DpHPzLbVApFd1IFhcnBjREYXYcg==", "dev": true, "license": "MIT", "peer": true, diff --git a/package.json b/package.json index dfc870b94..fea49e02e 100644 --- a/package.json +++ b/package.json @@ -138,6 +138,7 @@ "svgmap": "2.19.3", "tablemark": "4.1.0", "twitter-api-v2": "1.29.0", + "undici": "7.24.4", "yahoo-finance2": "3.14.2", "zone.js": "0.16.1" },