1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-10 13:50:05 +00:00

fix(requests): only allow insecure requests if https module is available

This commit is contained in:
Krishna Acondy
2021-02-06 13:00:27 +00:00
parent 851b6bc273
commit d8176912cf

View File

@@ -45,12 +45,18 @@ export class RequestClient implements HttpClient {
constructor(private baseUrl: string, allowInsecure = false) { constructor(private baseUrl: string, allowInsecure = false) {
const https = require('https') const https = require('https')
this.httpClient = axios.create({ if (allowInsecure && https.Agent) {
baseURL: baseUrl, this.httpClient = axios.create({
httpsAgent: new https.Agent({ baseURL: baseUrl,
rejectUnauthorized: !allowInsecure httpsAgent: new https.Agent({
rejectUnauthorized: !allowInsecure
})
}) })
}) } else {
this.httpClient = axios.create({
baseURL: baseUrl
})
}
} }
public getCsrfToken(type: 'general' | 'file' = 'general') { public getCsrfToken(type: 'general' | 'file' = 'general') {