forked from XiaoMo/ChatGPT-Next-Web
Fix & Feat [Auth] Api Key Variable
- [+] fix(auth.ts): fix variable name from serverApiKey to systemApiKey - [+] feat(auth.ts): add support for Google API key in addition to Azure API key
This commit is contained in:
parent
bda3098a31
commit
35471a41c8
@ -55,15 +55,18 @@ export function auth(req: NextRequest) {
|
|||||||
|
|
||||||
// if user does not provide an api key, inject system api key
|
// if user does not provide an api key, inject system api key
|
||||||
if (!apiKey) {
|
if (!apiKey) {
|
||||||
const serverApiKey = serverConfig.isAzure
|
const serverConfig = getServerSideConfig();
|
||||||
|
const systemApiKey = serverConfig.isAzure
|
||||||
? serverConfig.azureApiKey
|
? serverConfig.azureApiKey
|
||||||
|
: serverConfig.isGoogle
|
||||||
|
? serverConfig.googleApiKey
|
||||||
: serverConfig.apiKey;
|
: serverConfig.apiKey;
|
||||||
|
|
||||||
if (serverApiKey) {
|
if (systemApiKey) {
|
||||||
console.log("[Auth] use system api key");
|
console.log("[Auth] use system api key");
|
||||||
req.headers.set(
|
req.headers.set(
|
||||||
"Authorization",
|
"Authorization",
|
||||||
`${serverConfig.isAzure ? "" : "Bearer "}${serverApiKey}`,
|
`Bearer ${systemApiKey}`,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
console.log("[Auth] admin did not provide an api key");
|
console.log("[Auth] admin did not provide an api key");
|
||||||
|
Loading…
Reference in New Issue
Block a user