import type { NextApiRequest, NextApiResponse } from "next"; import { listDocs, readDoc } from "@/lib/docs"; // The proxy authenticates this endpoint, including index content. export default async function handler(request: NextApiRequest, response: NextApiResponse) { response.setHeader("Cache-Control", "private, no-store"); if (request.method !== "GET") { response.setHeader("Allow", "GET"); return response.status(405).end(); } const docs = await listDocs(); const index = await Promise.all(docs.map(async (doc) => ({ ...doc, searchText: (await readDoc(doc.slug)).content, }))); response.status(200).json(index); }