Deploy
This commit is contained in:
@@ -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 || '76a26aa4-de8e-4e6d-b4ed-8301ab127c6d'
|
||||
|
||||
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, { cache: 'no-store' })
|
||||
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: [] })
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user