Skip to content

Commit

Permalink
feat: use api key in headers only if jwt not presented (#277)(#283)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikitabut authored Dec 13, 2023
1 parent f24b37f commit 4ba9a92
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/utils/server/get-headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,17 @@ export const getApiHeaders = ({
}): Record<string, string> => {
const headers: Record<string, string> = {
'Content-Type': 'application/json',
'Api-Key': process.env.OPENAI_API_KEY,
};
if (chatId) {
headers['X-CONVERSATION-ID'] = chatId;
}

if (jwt) {
headers['authorization'] = 'Bearer ' + jwt;
} else {
headers['Api-Key'] = process.env.OPENAI_API_KEY;
}

if (jobTitle) {
headers['X-JOB-TITLE'] = jobTitle;
}
Expand Down

0 comments on commit 4ba9a92

Please sign in to comment.