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:
@@ -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') {
|
||||||
|
|||||||
Reference in New Issue
Block a user