Skip to content

Commit

Permalink
Merge pull request #171 from lukeshumard/nextjs-route-params
Browse files Browse the repository at this point in the history
fix: allow params to be passed through Next.js App Router verify
  • Loading branch information
ogzhanolguncu authored Sep 3, 2024
2 parents f86ad8a + bd855e2 commit a57b350
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions platforms/nextjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ type VerifySignatureAppRouterResponse =

export function verifySignatureAppRouter(
handler:
| ((request: Request) => VerifySignatureAppRouterResponse)
| ((request: NextRequest) => VerifySignatureAppRouterResponse),
| ((request: Request, params?: unknown) => VerifySignatureAppRouterResponse)
| ((request: NextRequest, params?: unknown) => VerifySignatureAppRouterResponse),
config?: VerifySignatureConfig
) {
const currentSigningKey = config?.currentSigningKey ?? process.env.QSTASH_CURRENT_SIGNING_KEY;
Expand All @@ -169,7 +169,7 @@ export function verifySignatureAppRouter(
nextSigningKey,
});

return async (request: NextRequest | Request) => {
return async (request: NextRequest | Request, params?: unknown) => {
const requestClone = request.clone() as NextRequest;
const signature = request.headers.get("upstash-signature");
if (!signature) {
Expand All @@ -191,7 +191,7 @@ export function verifySignatureAppRouter(
return new NextResponse(new TextEncoder().encode("invalid signature"), { status: 403 });
}

return handler(request as NextRequest);
return handler(request as NextRequest, params);
};
}

Expand Down

0 comments on commit a57b350

Please sign in to comment.