Skip to content

Open Source Wealth Management Software. Angular + NestJS + Prisma + Nx + TypeScript 🤍

Task/respect HTTP_PROXY environment variables for outbound HTTP requests (#6952)

Thomas Kaul8156e4057bf7
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a7817256f4..d82e7dd195 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 f08a09a83a..94e389f6a4 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>(ConfigService);
let customLogLevels: LogLevel[];
diff --git a/package-lock.json b/package-lock.json
index 7a06ea1b31..6527c6bc4f 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 dfc870b946..fea49e02ee 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"
},