Skip to content

Commit

Permalink
Merge pull request #179 from Yidadaa/prompt
Browse files Browse the repository at this point in the history
fix: middleware match error
  • Loading branch information
Yidadaa authored Mar 29, 2023
2 parents d908099 + 53e30e2 commit 9c6f3eb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ACCESS_CODES } from "./app/api/access";
import md5 from "spark-md5";

export const config = {
matcher: ["/api/chat", "/api/chat-stream"],
matcher: ["/api/openai", "/api/chat-stream"],
};

export function middleware(req: NextRequest) {
Expand Down Expand Up @@ -32,6 +32,7 @@ export function middleware(req: NextRequest) {
if (!token) {
const apiKey = process.env.OPENAI_API_KEY;
if (apiKey) {
console.log("[Auth] set system token");
req.headers.set("token", apiKey);
} else {
return NextResponse.json(
Expand All @@ -44,6 +45,8 @@ export function middleware(req: NextRequest) {
},
);
}
} else {
console.log("[Auth] set user token");
}

return NextResponse.next({
Expand Down

1 comment on commit 9c6f3eb

@vercel
Copy link

@vercel vercel bot commented on 9c6f3eb Mar 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.