Fix TypeScript error: params must be Promise in Next.js 15
This commit is contained in:
parent
cecfcfb620
commit
d5037b35a9
1 changed files with 12 additions and 8 deletions
|
|
@ -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[]) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue