This commit is contained in:
2025-02-02 17:24:12 -06:00
parent 29c3523233
commit 1512a4fe2f
9 changed files with 1702 additions and 109 deletions

41
src/pages/api/auth.ts Normal file
View File

@ -0,0 +1,41 @@
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,
}
);
}
};