mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-05-19 20:20:16 +09:00
fix: built-in plugin dalle3 error #5787
This commit is contained in:
parent
108069a0c6
commit
2b0f2e5f9d
@ -1,4 +1,5 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
import { getServerSideConfig } from "@/app/config/server";
|
||||||
|
|
||||||
export async function handle(
|
export async function handle(
|
||||||
req: NextRequest,
|
req: NextRequest,
|
||||||
@ -9,6 +10,7 @@ export async function handle(
|
|||||||
if (req.method === "OPTIONS") {
|
if (req.method === "OPTIONS") {
|
||||||
return NextResponse.json({ body: "OK" }, { status: 200 });
|
return NextResponse.json({ body: "OK" }, { status: 200 });
|
||||||
}
|
}
|
||||||
|
const serverConfig = getServerSideConfig();
|
||||||
|
|
||||||
// remove path params from searchParams
|
// remove path params from searchParams
|
||||||
req.nextUrl.searchParams.delete("path");
|
req.nextUrl.searchParams.delete("path");
|
||||||
@ -31,6 +33,11 @@ export async function handle(
|
|||||||
return true;
|
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 controller = new AbortController();
|
||||||
const fetchOptions: RequestInit = {
|
const fetchOptions: RequestInit = {
|
||||||
headers,
|
headers,
|
||||||
|
Loading…
Reference in New Issue
Block a user