Yifei Zhang 1 year ago
parent
commit
cd9799588d
1 changed files with 6 additions and 1 deletions
  1. 6 1
      middleware.ts

+ 6 - 1
middleware.ts

@@ -31,6 +31,7 @@ export function middleware(req: NextRequest) {
   // inject api key
   if (!token) {
     const apiKey = process.env.OPENAI_API_KEY;
+    console.log("apiKey", apiKey);
     if (apiKey) {
       req.headers.set("token", apiKey);
     } else {
@@ -46,5 +47,9 @@ export function middleware(req: NextRequest) {
     }
   }
 
-  return NextResponse.next();
+  return NextResponse.next({
+    request: {
+      headers: req.headers,
+    },
+  });
 }