Skip to content

Commit

Permalink
Fix/import https proxy package only when needed (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebbi08 committed Jun 13, 2024
1 parent 0d41ea8 commit 0f5d872
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/runtime/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nmshd/runtime",
"version": "4.12.0",
"version": "4.12.1",
"description": "The enmeshed client runtime.",
"homepage": "https://enmeshed.eu",
"repository": {
Expand Down Expand Up @@ -59,7 +59,7 @@
"@nmshd/consumption": "3.12.0",
"@nmshd/content": "2.11.0",
"@nmshd/crypto": "2.0.6",
"@nmshd/transport": "2.8.0",
"@nmshd/transport": "2.8.1",
"ajv": "^8.16.0",
"ajv-errors": "^3.0.0",
"ajv-formats": "^3.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/transport/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nmshd/transport",
"version": "2.8.0",
"version": "2.8.1",
"description": "The transport library handles backbone communication and content encryption.",
"homepage": "https://enmeshed.eu",
"repository": {
Expand Down
11 changes: 8 additions & 3 deletions packages/transport/src/core/backbone/RESTClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";
import formDataLib from "form-data";
import { AgentOptions } from "http";
import { AgentOptions as HTTPSAgentOptions } from "https";
import { HttpsProxyAgent } from "https-proxy-agent";
import _ from "lodash";
import { TransportLoggerFactory } from "../TransportLoggerFactory";
import { CoreId } from "../types";
Expand Down Expand Up @@ -84,8 +83,14 @@ export class RESTClient {
const resultingRequestConfig = _.defaultsDeep(defaults, requestConfig);

if (typeof window === "undefined" && (process.env.https_proxy ?? process.env.HTTPS_PROXY)) {
const httpsProxy = (process.env.https_proxy ?? process.env.HTTPS_PROXY)!;
resultingRequestConfig.httpsAgent = new HttpsProxyAgent(httpsProxy, this.config.httpsAgentOptions);
try {
const httpsProxy = (process.env.https_proxy ?? process.env.HTTPS_PROXY)!;
// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/naming-convention
const HttpsProxyAgent = require("https-proxy-agent").HttpsProxyAgent;
resultingRequestConfig.httpsAgent = new HttpsProxyAgent(httpsProxy, this.config.httpsAgentOptions);
} catch (e) {
// ignore
}
} else {
try {
// eslint-disable-next-line @typescript-eslint/no-require-imports
Expand Down

0 comments on commit 0f5d872

Please sign in to comment.