fix: await params in API route handlers for Next.js 16 compatibility

In Next.js 16, route handler params are now async Promises.
Updated all HTTP method handlers (GET, POST, PUT, DELETE, PATCH)
to properly await the params before accessing path segments.

This fixes the build error:
"Type 'Promise<{ path: string[] }>' is not assignable to type '{ path: string[] }'"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
valknarness
2025-11-07 16:10:30 +01:00
parent 27ff7f7ffd
commit ea44b592dd

View File

@@ -15,37 +15,42 @@ const PASTEL_API_URL = process.env.PASTEL_API_URL || 'http://localhost:3001';
export async function GET(
request: NextRequest,
{ params }: { params: { path: string[] } }
{ params }: { params: Promise<{ path: string[] }> }
) {
return proxyRequest(request, params.path, 'GET');
const { path } = await params;
return proxyRequest(request, path, 'GET');
}
export async function POST(
request: NextRequest,
{ params }: { params: { path: string[] } }
{ params }: { params: Promise<{ path: string[] }> }
) {
return proxyRequest(request, params.path, 'POST');
const { path } = await params;
return proxyRequest(request, path, 'POST');
}
export async function PUT(
request: NextRequest,
{ params }: { params: { path: string[] } }
{ params }: { params: Promise<{ path: string[] }> }
) {
return proxyRequest(request, params.path, 'PUT');
const { path } = await params;
return proxyRequest(request, path, 'PUT');
}
export async function DELETE(
request: NextRequest,
{ params }: { params: { path: string[] } }
{ params }: { params: Promise<{ path: string[] }> }
) {
return proxyRequest(request, params.path, 'DELETE');
const { path } = await params;
return proxyRequest(request, path, 'DELETE');
}
export async function PATCH(
request: NextRequest,
{ params }: { params: { path: string[] } }
{ params }: { params: Promise<{ path: string[] }> }
) {
return proxyRequest(request, params.path, 'PATCH');
const { path } = await params;
return proxyRequest(request, path, 'PATCH');
}
async function proxyRequest(