Skip to content

Commit

Permalink
fix: built-in plugin dalle3 error ChatGPTNextWeb#5787
Browse files Browse the repository at this point in the history
  • Loading branch information
JingSyue authored and all4fun committed Nov 17, 2024
1 parent 3069c6d commit 11afec8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/api/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NextRequest, NextResponse } from "next/server";
import { getServerSideConfig } from "@/app/config/server";

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

// remove path params from searchParams
req.nextUrl.searchParams.delete("path");
Expand All @@ -31,6 +33,11 @@ export async function handle(
return true;
}),
);
// if dalle3 use openai api key
if (req.headers.get("x-base-url")?.includes("openai")) {
headers.set("Authorization", `Bearer ${serverConfig.apiKey}`);
}

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

0 comments on commit 11afec8

Please sign in to comment.