We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2b0f2e5 commit 18a6571Copy full SHA for 18a6571
app/api/proxy.ts
@@ -34,9 +34,16 @@ export async function handle(
34
}),
35
);
36
// if dalle3 use openai api key
37
- if (req.headers.get("x-base-url")?.includes("openai")) {
38
- headers.set("Authorization", `Bearer ${serverConfig.apiKey}`);
39
- }
+ const baseUrl = req.headers.get("x-base-url");
+ if (baseUrl?.includes("api.openai.com")) {
+ if (!serverConfig.apiKey) {
40
+ return NextResponse.json(
41
+ { error: "OpenAI API key not configured" },
42
+ { status: 500 },
43
+ );
44
+ }
45
+ headers.set("Authorization", `Bearer ${serverConfig.apiKey}`);
46
47
48
const controller = new AbortController();
49
const fetchOptions: RequestInit = {
0 commit comments