File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -6,11 +6,12 @@ import { AppRouteRequestHandlerOptions } from '.';
66import { RPCApiHandler } from '../api' ;
77import { loadAssets } from '../shared' ;
88
9- type Context = { params : Promise < { path : string [ ] } > } ;
9+ type Context = { params : Promise < { path : string [ ] } > | { path : string [ ] } } ;
1010
1111/**
1212 * Creates a Next.js 13 "app dir" API route request handler which encapsulates Prisma CRUD operations.
1313 *
14+ * @remarks Since Next.js 15, `context.params` is asynchronous and must be awaited.
1415 * @param options Options for initialization
1516 * @returns An API route request handler
1617 */
@@ -27,10 +28,16 @@ export default function factory(
2728 return NextResponse . json ( { message : 'unable to get prisma from request context' } , { status : 500 } ) ;
2829 }
2930
31+ let params : Context [ 'params' ] ;
3032 const url = new URL ( req . url ) ;
31- const params = await context . params ;
3233 const query = Object . fromEntries ( url . searchParams ) ;
3334
35+ try {
36+ params = await context . params ;
37+ } catch {
38+ return NextResponse . json ( { message : 'Failed to resolve request parameters' } , { status : 500 } ) ;
39+ }
40+
3441 if ( ! params . path ) {
3542 return NextResponse . json (
3643 { message : 'missing path parameter' } ,
You can’t perform that action at this time.
0 commit comments