Fix Next.js 16 async params in dynamic route
Some checks failed
Build and Push Docker Images / docker (push) Failing after 2m11s

Next.js 16 breaking change: route params are now Promises
- Updated GET, PATCH, DELETE handlers to await params
- Changed signature from { params: { id: string } }
  to { params: Promise<{ id: string }> }
- Extract id with: const { id } = await params;
This commit is contained in:
Matt 2025-11-03 11:07:44 +01:00
parent cfa7e88ed2
commit 10b277b853

View File

@ -7,10 +7,11 @@ import { nocodbClient } from '@/api/nocodbClient';
*/
export async function GET(
request: NextRequest,
{ params }: { params: { id: string } }
{ params }: { params: Promise<{ id: string }> }
) {
try {
const order = await nocodbClient.getOrderById(params.id);
const { id } = await params;
const order = await nocodbClient.getOrderById(id);
return NextResponse.json({
success: true,
@ -34,11 +35,12 @@ export async function GET(
*/
export async function PATCH(
request: NextRequest,
{ params }: { params: { id: string } }
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params;
const body = await request.json();
const updatedOrder = await nocodbClient.updateOrder(params.id, body);
const updatedOrder = await nocodbClient.updateOrder(id, body);
return NextResponse.json({
success: true,
@ -62,11 +64,12 @@ export async function PATCH(
*/
export async function DELETE(
request: NextRequest,
{ params }: { params: { id: string } }
{ params }: { params: Promise<{ id: string }> }
) {
try {
const { id } = await params;
// Instead of actually deleting, update status to "cancelled"
await nocodbClient.updateOrderStatus(params.id, 'cancelled');
await nocodbClient.updateOrderStatus(id, 'cancelled');
return NextResponse.json({
success: true,