14 lines
649 B
TypeScript
14 lines
649 B
TypeScript
import type { NextApiRequest, NextApiResponse } from "next";
|
|
import { readResearchSnapshot } from "@/lib/ai-research-store";
|
|
|
|
// The site's existing proxy protects this endpoint with the same login session.
|
|
export default 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();
|
|
}
|
|
try { return response.status(200).json(readResearchSnapshot()); }
|
|
catch { return response.status(503).json({ error: "研究数据库暂时不可用,请稍后重试" }); }
|
|
}
|