File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change 1
1
import { NextRequest , NextResponse } from "next/server" ;
2
+ import { getServerSideConfig } from "@/app/config/server" ;
2
3
3
4
export async function handle (
4
5
req : NextRequest ,
@@ -9,6 +10,7 @@ export async function handle(
9
10
if ( req . method === "OPTIONS" ) {
10
11
return NextResponse . json ( { body : "OK" } , { status : 200 } ) ;
11
12
}
13
+ const serverConfig = getServerSideConfig ( ) ;
12
14
13
15
// remove path params from searchParams
14
16
req . nextUrl . searchParams . delete ( "path" ) ;
@@ -31,6 +33,11 @@ export async function handle(
31
33
return true ;
32
34
} ) ,
33
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
+ }
40
+
34
41
const controller = new AbortController ( ) ;
35
42
const fetchOptions : RequestInit = {
36
43
headers,
You can’t perform that action at this time.
0 commit comments