This commit is contained in:
Vula Builder
2026-07-27 19:00:01 +00:00
parent fddb1c8944
commit 924fef1f58
+24
View File
@@ -0,0 +1,24 @@
import { NextRequest, NextResponse } from 'next/server'
const VULA_CMS_URL = process.env.VULA_CMS_URL || 'https://ide.vulai.co.za'
const VULA_CMS_PROJECT_ID = process.env.VULA_CMS_PROJECT_ID || ''
export async function GET(
request: NextRequest,
{ params }: { params: Promise<{ collection: string }> }
) {
const { collection } = await params
if (!VULA_CMS_PROJECT_ID) return NextResponse.json({ items: [] })
try {
const { searchParams } = request.nextUrl
const status = searchParams.get('status') || 'published'
const limit = searchParams.get('limit') || '20'
const url = `${VULA_CMS_URL}/api/public/cms/${VULA_CMS_PROJECT_ID}/${collection}?status=${status}&limit=${limit}`
const res = await fetch(url, { next: { revalidate: 60 } })
if (!res.ok) return NextResponse.json({ items: [] })
const json = await res.json() as { items?: unknown[] }
return NextResponse.json({ items: json.items ?? [] })
} catch {
return NextResponse.json({ items: [] })
}
}