Skip to content

Commit e5ee13d

Browse files
committed
🐞 fix (server): support for awaiting next.js 15 params
1 parent fac631b commit e5ee13d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

packages/server/src/next/app-route-handler.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { AppRouteRequestHandlerOptions } from '.';
66
import { RPCApiHandler } from '../api';
77
import { loadAssets } from '../shared';
88

9-
type Context = { params: { path: string[] } };
9+
type Context = { params: Promise<{ path: string[] }> };
1010

1111
/**
1212
* Creates a Next.js 13 "app dir" API route request handler which encapsulates Prisma CRUD operations.
@@ -28,17 +28,18 @@ export default function factory(
2828
}
2929

3030
const url = new URL(req.url);
31+
const params = await context.params;
3132
const query = Object.fromEntries(url.searchParams);
3233

33-
if (!context.params.path) {
34+
if (!params.path) {
3435
return NextResponse.json(
3536
{ message: 'missing path parameter' },
3637
{
3738
status: 400,
3839
}
3940
);
4041
}
41-
const path = context.params.path.join('/');
42+
const path = params.path.join('/');
4243

4344
let requestBody: unknown;
4445
if (req.body) {

0 commit comments

Comments
 (0)