Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions apps/generator-cli/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Inject, Module, OnApplicationBootstrap } from '@nestjs/common';
import { HttpModule, HttpModuleOptions } from '@nestjs/axios';
import { Command } from 'commander';
import { ProxyAgent } from 'proxy-agent';

import { COMMANDER_PROGRAM, LOGGER } from './constants';
import { VersionManagerController } from './controllers/version-manager.controller';
Expand All @@ -17,16 +16,18 @@ const hasHttpProxyEnvs = process.env.HTTP_PROXY || process.env.http_proxy;
const hasHttpsProxyEnvs = process.env.HTTPS_PROXY || process.env.https_proxy;
const httpModuleConfig: HttpModuleOptions = {};

const proxyAgent = new ProxyAgent();

if (hasHttpProxyEnvs) {
httpModuleConfig.proxy = false;
httpModuleConfig.httpAgent = proxyAgent;
// eslint-disable-next-line @typescript-eslint/no-var-requires
const ProxyAgent = require('proxy-agent').default ?? require('proxy-agent');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: proxy-agent v8 should be imported via its named export; this require fallback can break when proxy env vars are set.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/generator-cli/src/app/app.module.ts, line 22:

<comment>proxy-agent v8 should be imported via its named export; this require fallback can break when proxy env vars are set.</comment>

<file context>
@@ -17,16 +16,18 @@ const hasHttpProxyEnvs = process.env.HTTP_PROXY || process.env.http_proxy;
   httpModuleConfig.proxy = false;
-  httpModuleConfig.httpAgent = proxyAgent;
+  // eslint-disable-next-line @typescript-eslint/no-var-requires
+  const ProxyAgent = require('proxy-agent').default ?? require('proxy-agent');
+  httpModuleConfig.httpAgent = new ProxyAgent();
 }
</file context>

Tip: Review your code locally with the cubic CLI to iterate faster.

httpModuleConfig.httpAgent = new ProxyAgent();
}

if (hasHttpsProxyEnvs) {
httpModuleConfig.proxy = false;
httpModuleConfig.httpsAgent = proxyAgent;
// eslint-disable-next-line @typescript-eslint/no-var-requires
const ProxyAgent = require('proxy-agent').default ?? require('proxy-agent');
httpModuleConfig.httpsAgent = new ProxyAgent();
}

@Module({
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
"fs-extra": "11.3.4",
"glob": "13.x",
"jsonpath": "1.3.0",
"proxy-agent": "^6.4.0",
"proxy-agent": "^8.0.1",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.2",
"tslib": "^2.3.0"
Expand Down Expand Up @@ -127,13 +127,13 @@
"jest": "30.3.0",
"jest-environment-jsdom": "30.3.0",
"jest-environment-node": "^30.0.0",
"jest-util": "30.3.0",
"nx": "22.6.0",
"prettier": "3.8.1",
"semantic-release": "24.2.9",
"ts-jest": "29.4.9",
"ts-node": "10.9.2",
"type-fest": "5.5.0",
"typescript": "5.9.3",
"jest-util": "30.3.0"
"typescript": "5.9.3"
}
}
Loading