Skip to content

Commit

Permalink
Removed HTTPS_AGENT verification (#427)
Browse files Browse the repository at this point in the history
* Removed HTTPS_AGENT verification
* Fixed code smell
  • Loading branch information
petruki authored Jun 26, 2023
1 parent 8e4f802 commit 382d3d3
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/client/relay/index.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import axios from 'axios';
import https from 'https';
import { StrategiesToRelayDataType, RelayMethods } from '../../models/config';
import { checkHttpsAgent } from '../../external/switcher-api-facade';

const agent = async (url) => {
const rejectUnauthorized = !(await checkHttpsAgent(url));
const agent = async () => {
const rejectUnauthorized = false;
return new https.Agent({ rejectUnauthorized });
};

Expand Down Expand Up @@ -48,15 +47,15 @@ export async function resolveVerification(relay, environment) {

async function post(url, data, headers) {
try {
return await axios.post(url, data, { httpsAgent: await agent(url), headers });
return await axios.post(url, data, { httpsAgent: await agent(), headers });
} catch (error) {
throw new Error(`Failed to reach ${url} via POST`);
}
}

async function get(url, data, headers) {
try {
return await axios.get(`${url}${data}`, { httpsAgent: await agent(url), headers });
return await axios.get(`${url}${data}`, { httpsAgent: await agent(), headers });
} catch (error) {
throw new Error(`Failed to reach ${url} via GET`);
}
Expand Down

0 comments on commit 382d3d3

Please sign in to comment.