mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-04-07 00:15:23 +02:00
fix: Add proxy support for Graph API client creation
This commit is contained in:
parent
de8ae92439
commit
dcb3f342b2
1 changed files with 7 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ const { getOpenIdConfig } = require('~/strategies/openidStrategy');
|
|||
const getLogStores = require('~/cache/getLogStores');
|
||||
const nodeFetch = require('node-fetch');
|
||||
const { HttpsProxyAgent } = require('https-proxy-agent');
|
||||
const { ProxyAgent } = require('undici');
|
||||
|
||||
/**
|
||||
* @import { TPrincipalSearchResult, TGraphPerson, TGraphUser, TGraphGroup, TGraphPeopleResponse, TGraphUsersResponse, TGraphGroupsResponse } from 'librechat-data-provider'
|
||||
|
|
@ -40,10 +41,16 @@ const createGraphClient = async (accessToken, sub) => {
|
|||
const openidConfig = getOpenIdConfig();
|
||||
const exchangedToken = await exchangeTokenForGraphAccess(openidConfig, accessToken, sub);
|
||||
|
||||
const fetchOptions = {};
|
||||
// Add proxy support if configured
|
||||
if (process.env.PROXY) {
|
||||
fetchOptions.dispatcher = new ProxyAgent(process.env.PROXY);
|
||||
}
|
||||
const graphClient = Client.init({
|
||||
authProvider: (done) => {
|
||||
done(null, exchangedToken);
|
||||
},
|
||||
fetchOptions,
|
||||
});
|
||||
|
||||
return graphClient;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue