Skip to content

Commit

Permalink
Update proxy.ts
Browse files Browse the repository at this point in the history
Update proxy.ts
  • Loading branch information
JingSyue authored Nov 11, 2024
1 parent 2b0f2e5 commit 18a6571
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions app/api/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,16 @@ export async function handle(
}),
);
// if dalle3 use openai api key
if (req.headers.get("x-base-url")?.includes("openai")) {
headers.set("Authorization", `Bearer ${serverConfig.apiKey}`);
}
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}`);
}

const controller = new AbortController();
const fetchOptions: RequestInit = {
Expand Down

0 comments on commit 18a6571

Please sign in to comment.