🎯 feat(config): Custom Endpoint Request Headers (#1588)

This commit is contained in:
Danny Avila 2024-01-18 20:11:42 -05:00 committed by GitHub
parent ab3339210a
commit 7e2e19a134
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 25 additions and 1 deletions

View file

@ -22,6 +22,13 @@ const initializeClient = async ({ req, res, endpointOption }) => {
const CUSTOM_API_KEY = extractEnvVariable(endpointConfig.apiKey);
const CUSTOM_BASE_URL = extractEnvVariable(endpointConfig.baseURL);
let resolvedHeaders = {};
if (endpointConfig.headers && typeof endpointConfig.headers === 'object') {
Object.keys(endpointConfig.headers).forEach((key) => {
resolvedHeaders[key] = extractEnvVariable(endpointConfig.headers[key]);
});
}
if (CUSTOM_API_KEY.match(envVarRegex)) {
throw new Error(`Missing API Key for ${endpoint}.`);
}
@ -31,6 +38,7 @@ const initializeClient = async ({ req, res, endpointOption }) => {
}
const customOptions = {
headers: resolvedHeaders,
addParams: endpointConfig.addParams,
dropParams: endpointConfig.dropParams,
titleConvo: endpointConfig.titleConvo,