fix: update route handler to use async params for Next.js 16
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
import { NextRequest, NextResponse } from "next/server";
|
import { NextRequest, NextResponse } from "next/server";
|
||||||
|
|
||||||
export async function GET(req: NextRequest, { params }: { params: { path: string[] } }) {
|
export async function GET(req: NextRequest, { params }: { params: Promise<{ path: string[] }> }) {
|
||||||
const path = params.path?.join("/") || "";
|
const { path: pathArray } = await params;
|
||||||
|
const path = pathArray?.join("/") || "";
|
||||||
const token = req.headers.get("authorization");
|
const token = req.headers.get("authorization");
|
||||||
const host = req.headers.get("host");
|
const host = req.headers.get("host");
|
||||||
|
|
||||||
@@ -24,8 +25,9 @@ export async function GET(req: NextRequest, { params }: { params: { path: string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function PUT(req: NextRequest, { params }: { params: { path: string[] } }) {
|
export async function PUT(req: NextRequest, { params }: { params: Promise<{ path: string[] }> }) {
|
||||||
const path = params.path?.join("/") || "";
|
const { path: pathArray } = await params;
|
||||||
|
const path = pathArray?.join("/") || "";
|
||||||
const token = req.headers.get("authorization");
|
const token = req.headers.get("authorization");
|
||||||
const host = req.headers.get("host");
|
const host = req.headers.get("host");
|
||||||
const body = await req.json();
|
const body = await req.json();
|
||||||
@@ -50,8 +52,9 @@ export async function PUT(req: NextRequest, { params }: { params: { path: string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function POST(req: NextRequest, { params }: { params: { path: string[] } }) {
|
export async function POST(req: NextRequest, { params }: { params: Promise<{ path: string[] }> }) {
|
||||||
const path = params.path?.join("/") || "";
|
const { path: pathArray } = await params;
|
||||||
|
const path = pathArray?.join("/") || "";
|
||||||
const token = req.headers.get("authorization");
|
const token = req.headers.get("authorization");
|
||||||
const host = req.headers.get("host");
|
const host = req.headers.get("host");
|
||||||
const body = await req.json();
|
const body = await req.json();
|
||||||
@@ -74,4 +77,4 @@ export async function POST(req: NextRequest, { params }: { params: { path: strin
|
|||||||
console.error("API proxy error:", error);
|
console.error("API proxy error:", error);
|
||||||
return NextResponse.json({ error: "Internal Server Error" }, { status: 500 });
|
return NextResponse.json({ error: "Internal Server Error" }, { status: 500 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user