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