Skip to content

Commit 7682a88

Browse files
committed
chore(fix): fix proxy agent
1 parent 3ff8c70 commit 7682a88

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

apps/generator-cli/src/app/app.module.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Inject, Module, OnApplicationBootstrap } from '@nestjs/common';
22
import { HttpModule, HttpModuleOptions } from '@nestjs/axios';
33
import { Command } from 'commander';
4+
import { ProxyAgent } from 'proxy-agent';
45

56
import { COMMANDER_PROGRAM, LOGGER } from './constants';
67
import { VersionManagerController } from './controllers/version-manager.controller';
@@ -15,19 +16,16 @@ import {
1516
const hasHttpProxyEnvs = process.env.HTTP_PROXY || process.env.http_proxy;
1617
const hasHttpsProxyEnvs = process.env.HTTPS_PROXY || process.env.https_proxy;
1718
const httpModuleConfig: HttpModuleOptions = {};
19+
const proxyAgent = new ProxyAgent();
1820

1921
if (hasHttpProxyEnvs) {
2022
httpModuleConfig.proxy = false;
21-
// eslint-disable-next-line @typescript-eslint/no-var-requires
22-
const ProxyAgent = require('proxy-agent').default ?? require('proxy-agent');
23-
httpModuleConfig.httpAgent = new ProxyAgent();
23+
httpModuleConfig.httpAgent = proxyAgent;
2424
}
2525

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

3331
@Module({

0 commit comments

Comments
 (0)