Update proxy.ts

Update proxy.ts
This commit is contained in:
JingSyue 2024-11-11 12:59:29 +08:00 committed by GitHub
parent 2b0f2e5f9d
commit 18a6571883
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 3 deletions

View File

@ -34,7 +34,14 @@ export async function handle(
}), }),
); );
// if dalle3 use openai api key // if dalle3 use openai api key
if (req.headers.get("x-base-url")?.includes("openai")) { const baseUrl = req.headers.get("x-base-url");
if (baseUrl?.includes("api.openai.com")) {
if (!serverConfig.apiKey) {
return NextResponse.json(
{ error: "OpenAI API key not configured" },
{ status: 500 },
);
}
headers.set("Authorization", `Bearer ${serverConfig.apiKey}`); headers.set("Authorization", `Bearer ${serverConfig.apiKey}`);
} }