Skip to content

Commit 2b0f2e5

Browse files
author
JingSyue
committed
fix: built-in plugin dalle3 error ChatGPTNextWeb#5787
1 parent 108069a commit 2b0f2e5

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

app/api/proxy.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { NextRequest, NextResponse } from "next/server";
2+
import { getServerSideConfig } from "@/app/config/server";
23

34
export async function handle(
45
req: NextRequest,
@@ -9,6 +10,7 @@ export async function handle(
910
if (req.method === "OPTIONS") {
1011
return NextResponse.json({ body: "OK" }, { status: 200 });
1112
}
13+
const serverConfig = getServerSideConfig();
1214

1315
// remove path params from searchParams
1416
req.nextUrl.searchParams.delete("path");
@@ -31,6 +33,11 @@ export async function handle(
3133
return true;
3234
}),
3335
);
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+
}
40+
3441
const controller = new AbortController();
3542
const fetchOptions: RequestInit = {
3643
headers,

0 commit comments

Comments
 (0)