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:
@@ -15,37 +15,42 @@ const PASTEL_API_URL = process.env.PASTEL_API_URL || 'http://localhost:3001';
|
|||||||
|
|
||||||
export async function GET(
|
export async function GET(
|
||||||
request: NextRequest,
|
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(
|
export async function POST(
|
||||||
request: NextRequest,
|
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(
|
export async function PUT(
|
||||||
request: NextRequest,
|
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(
|
export async function DELETE(
|
||||||
request: NextRequest,
|
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(
|
export async function PATCH(
|
||||||
request: NextRequest,
|
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(
|
async function proxyRequest(
|
||||||
|
|||||||
Reference in New Issue
Block a user