import type { APIRoute } from "astro"; export const POST: APIRoute = async ({ request }) => { const headers = { "Content-Type": "application/json", }; try { const { code } = await request.json(); const secretCode = process.env.SECRET_CODE || import.meta.env.SECRET_CODE; if (!code || code !== secretCode) { return new Response( JSON.stringify({ success: false, error: "Invalid code", }), { status: 401, headers, } ); } return new Response(JSON.stringify({ success: true }), { status: 200, headers, }); } catch (error) { return new Response( JSON.stringify({ success: false, error: "Authentication failed", }), { status: 500, headers, } ); } };