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 11import { NextRequest , NextResponse } from "next/server" ;
2+ import { getServerSideConfig } from "@/app/config/server" ;
23
34export 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,
You can’t perform that action at this time.
0 commit comments