1
0
mirror of https://github.com/bitwarden/jslib synced 2025-12-22 19:23:24 +00:00

native fetch with proxy support on node api

This commit is contained in:
Kyle Spearrin
2019-06-24 11:07:26 -04:00
parent 6d82fb5bbc
commit bc5a6e02c1
8 changed files with 78 additions and 14 deletions

View File

@@ -1,4 +1,5 @@
import * as FormData from 'form-data';
import * as HttpsProxyAgent from 'https-proxy-agent';
import * as fe from 'node-fetch';
import { ApiService } from './api.service';
@@ -17,4 +18,12 @@ export class NodeApiService extends ApiService {
logoutCallback: (expired: boolean) => Promise<void>) {
super(tokenService, platformUtilsService, logoutCallback);
}
nativeFetch(request: Request): Promise<Response> {
const proxy = process.env.http_proxy || process.env.https_proxy;
if (proxy) {
(request as any).agent = new HttpsProxyAgent(proxy);
}
return fetch(request);
}
}