From 4b342411a1004763ea5e212ce7b889f78b2e4c98 Mon Sep 17 00:00:00 2001 From: Sunday Ogbonna Date: Thu, 15 Feb 2024 07:23:17 +0100 Subject: [PATCH 1/2] docs: update router return statement to include type casting --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 27fa73e..2a3e5fb 100644 --- a/README.md +++ b/README.md @@ -157,12 +157,13 @@ router return NextResponse.json({ user }); }); +// Make sure to cast the handler to `Promise` to prevent type error with next.js 14 app router in production/preview deployments. export async function GET(request: NextRequest, ctx: RequestContext) { - return router.run(request, ctx); + return router.run(request, ctx) as Promise; } export async function PUT(request: NextRequest, ctx: RequestContext) { - return router.run(request, ctx); + return router.run(request, ctx) as Promise; } ``` From 06bbeb1e7f87e2abd05429e0f78a5eb91799a831 Mon Sep 17 00:00:00 2001 From: Sunday Ogbonna Date: Thu, 15 Feb 2024 07:36:24 +0100 Subject: [PATCH 2/2] docs: update comment sentence --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2a3e5fb..63fa337 100644 --- a/README.md +++ b/README.md @@ -157,7 +157,7 @@ router return NextResponse.json({ user }); }); -// Make sure to cast the handler to `Promise` to prevent type error with next.js 14 app router in production/preview deployments. +// Make sure to cast the handler return to `Promise` to prevent type error with next.js 14 app router in production/preview deployments. export async function GET(request: NextRequest, ctx: RequestContext) { return router.run(request, ctx) as Promise; }