Fix TypeScript error: params must be Promise in Next.js 15

This commit is contained in:
TheMaddax 2025-10-28 08:08:57 -06:00
parent cecfcfb620
commit d5037b35a9

View file

@ -3,30 +3,34 @@ import { NextRequest, NextResponse } from 'next/server';
// This catch-all API route proxies all /api/* requests to the backend // This catch-all API route proxies all /api/* requests to the backend
export async function GET( export async function GET(
request: NextRequest, request: NextRequest,
{ params }: { params: { path: string[] } } { params }: { params: Promise<{ path: string[] }> }
) { ) {
return proxyToBackend(request, params.path); const { path } = await params;
return proxyToBackend(request, path);
} }
export async function POST( export async function POST(
request: NextRequest, request: NextRequest,
{ params }: { params: { path: string[] } } { params }: { params: Promise<{ path: string[] }> }
) { ) {
return proxyToBackend(request, params.path); const { path } = await params;
return proxyToBackend(request, path);
} }
export async function PUT( export async function PUT(
request: NextRequest, request: NextRequest,
{ params }: { params: { path: string[] } } { params }: { params: Promise<{ path: string[] }> }
) { ) {
return proxyToBackend(request, params.path); const { path } = await params;
return proxyToBackend(request, path);
} }
export async function DELETE( export async function DELETE(
request: NextRequest, request: NextRequest,
{ params }: { params: { path: string[] } } { params }: { params: Promise<{ path: string[] }> }
) { ) {
return proxyToBackend(request, params.path); const { path } = await params;
return proxyToBackend(request, path);
} }
async function proxyToBackend(request: NextRequest, pathSegments: string[]) { async function proxyToBackend(request: NextRequest, pathSegments: string[]) {