fix(axios): incorporate http(s)-proxy-agents
This commit is contained in:
@@ -50,6 +50,8 @@
|
||||
"graphql-type-json": "^0.3.2",
|
||||
"handlebars": "^4.7.7",
|
||||
"http-errors": "~1.6.3",
|
||||
"http-proxy-agent": "^7.0.0",
|
||||
"https-proxy-agent": "^7.0.1",
|
||||
"jsonwebtoken": "^9.0.0",
|
||||
"knex": "^2.4.0",
|
||||
"lodash.get": "^4.4.2",
|
||||
|
24
packages/backend/src/helpers/axios-with-proxy.ts
Normal file
24
packages/backend/src/helpers/axios-with-proxy.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import axios, { AxiosRequestConfig } from 'axios';
|
||||
import { HttpsProxyAgent } from 'https-proxy-agent';
|
||||
import { HttpProxyAgent } from 'http-proxy-agent';
|
||||
|
||||
const config: AxiosRequestConfig = {};
|
||||
const httpProxyUrl = process.env.http_proxy;
|
||||
const httpsProxyUrl = process.env.https_proxy;
|
||||
const supportsProxy = httpProxyUrl || httpsProxyUrl;
|
||||
|
||||
if (supportsProxy) {
|
||||
if (httpProxyUrl) {
|
||||
config.httpAgent = new HttpProxyAgent(process.env.http_proxy);
|
||||
}
|
||||
|
||||
if (httpsProxyUrl) {
|
||||
config.httpsAgent = new HttpsProxyAgent(process.env.https_proxy);
|
||||
}
|
||||
|
||||
config.proxy = false;
|
||||
}
|
||||
|
||||
const axiosWithProxyInstance = axios.create(config);
|
||||
|
||||
export default axiosWithProxyInstance;
|
@@ -1,3 +1,4 @@
|
||||
// TODO: replace with axios-with-proxy when needed
|
||||
import axios from 'axios';
|
||||
import appConfig from '../../config/app';
|
||||
import { DateTime } from 'luxon';
|
||||
|
@@ -1,3 +1,4 @@
|
||||
// TODO: replace with axios-with-proxy
|
||||
import axios from 'axios';
|
||||
import appConfig from '../config/app';
|
||||
import memoryCache from 'memory-cache';
|
||||
|
@@ -1,8 +1,10 @@
|
||||
import axios, { AxiosRequestConfig } from 'axios';
|
||||
export { AxiosInstance as IHttpClient } from 'axios';
|
||||
import { IHttpClientParams } from '@automatisch/types';
|
||||
import { URL } from 'url';
|
||||
import { AxiosRequestConfig } from 'axios';
|
||||
import { URL } from 'node:url';
|
||||
export { AxiosInstance as IHttpClient } from 'axios';
|
||||
|
||||
import HttpError from '../../errors/http';
|
||||
import axios from '../axios-with-proxy';
|
||||
|
||||
const removeBaseUrlForAbsoluteUrls = (
|
||||
requestConfig: AxiosRequestConfig
|
||||
|
Reference in New Issue
Block a user