mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-23 20:00:15 +01:00
fix: filter out unresolved placeholders from headers (thanks @MrunmayS)
This commit is contained in:
parent
a8babbcebf
commit
3508839d6d
1 changed files with 14 additions and 1 deletions
|
|
@ -29,10 +29,23 @@ const initializeClient = async ({ req, res, endpointOption, optionsOnly, overrid
|
|||
const CUSTOM_BASE_URL = extractEnvVariable(endpointConfig.baseURL);
|
||||
|
||||
const customUserVars = {};
|
||||
customUserVars.LIBRECHAT_CONVERSATION_ID = req.body.conversationId;
|
||||
if (req.body.conversationId) {
|
||||
customUserVars.LIBRECHAT_CONVERSATION_ID = req.body.conversationId;
|
||||
}
|
||||
|
||||
let resolvedHeaders = resolveHeaders(endpointConfig.headers, req.user, customUserVars);
|
||||
|
||||
// Filter out headers with unresolved placeholders
|
||||
const filteredHeaders = {};
|
||||
for (const [key, value] of Object.entries(resolvedHeaders)) {
|
||||
if (typeof value === 'string' && value.includes('{{') && value.includes('}}')) {
|
||||
continue;
|
||||
}
|
||||
filteredHeaders[key] = value;
|
||||
}
|
||||
|
||||
resolvedHeaders = filteredHeaders;
|
||||
|
||||
if (CUSTOM_API_KEY.match(envVarRegex)) {
|
||||
throw new Error(`Missing API Key for ${endpoint}.`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue