UPDATE: Update readme and Next 16.07 (CVE-2025-66478)
This commit is contained in:
21
src/app/api/[locale]/pf/[id]/route.ts
Normal file
21
src/app/api/[locale]/pf/[id]/route.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { loadPF } from '@/lib/loader'
|
||||
|
||||
export async function GET(
|
||||
req: NextRequest,
|
||||
{ params }: { params: Promise<{ id: string, locale: string }> }
|
||||
) {
|
||||
|
||||
const { id, locale } = await params
|
||||
const pfData = await loadPF([id], locale)
|
||||
const pf = pfData[id]
|
||||
|
||||
if (!pf) {
|
||||
return NextResponse.json({ error: 'PF info not found' }, { status: 404 })
|
||||
}
|
||||
|
||||
|
||||
return new NextResponse(JSON.stringify(pf), {
|
||||
headers: { "Content-Type": "application/json" }
|
||||
});
|
||||
}
|
||||
22
src/app/api/[locale]/pf/route.ts
Normal file
22
src/app/api/[locale]/pf/route.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { loadPF } from "@/lib/loader";
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
|
||||
export async function POST(request: NextRequest, { params }: { params: Promise<{ locale: string }> }) {
|
||||
try {
|
||||
const body = await request.json();
|
||||
const pfIds = body.pfIds as string[];
|
||||
const { locale } = await params;
|
||||
|
||||
if (!Array.isArray(pfIds) || pfIds.some(id => typeof id !== 'string')) {
|
||||
return NextResponse.json({ error: 'Invalid pfIds' }, { status: 400 });
|
||||
}
|
||||
|
||||
const pfData = await loadPF(pfIds, locale);
|
||||
|
||||
return new NextResponse(JSON.stringify(pfData), {
|
||||
headers: { "Content-Type": "application/json" }
|
||||
});
|
||||
} catch {
|
||||
return NextResponse.json({ error: 'Failed to load pf data' }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user