Skip to content
Merged
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
10 changes: 3 additions & 7 deletions src/client/relay/index.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
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));
return new https.Agent({ rejectUnauthorized });
};
const agent = new https.Agent({ rejectUnauthorized: false });

export function resolveNotification(relay, entry, environment) {
const url = relay.endpoint[environment];
Expand Down Expand Up @@ -48,15 +44,15 @@ export async function resolveVerification(relay, environment) {

async function post(url, data, headers) {
try {
return await axios.post(url, data, { httpsAgent: agent(url) }, headers);
return await axios.post(url, data, { httpsAgent: 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: agent(url) }, headers);
return await axios.get(`${url}${data}`, { httpsAgent: agent }, headers);
} catch (error) {
throw new Error(`Failed to reach ${url} via GET`);
}
Expand Down