email contacto cloudflare

This commit is contained in:
David Ascanio 2026-08-02 14:01:42 -03:00
parent 9aa0105fca
commit 5dc873580e
1 changed files with 6 additions and 26 deletions

View File

@ -1,5 +1,6 @@
import type { APIRoute } from "astro"; import type { APIRoute } from "astro";
import { prisma } from "../lib/prisma"; import { prisma } from "../lib/prisma";
import { sendEmailCf } from "../lib/email";
export const prerender = false; export const prerender = false;
@ -64,32 +65,11 @@ export const POST: APIRoute = async ({ request }) => {
}, },
}); });
} }
const emailApiKey = import.meta.env.EMAIL_API_KEY; await sendEmailCf(
{ nombre, email, mensaje },
const emailResponse = await fetch("https://flows2.carpa.com/webhook/email/send", { "joseperez@centrodelreinodepazyjusticia.com",
method: "POST", "CENTRO_DEL_REINO_PAZ_Y_JUSTICIA_INFO",
headers: {
"Content-Type": "application/json",
"x-api-key": emailApiKey!,
},
body: JSON.stringify({
type: "CENTRO_DEL_REINO_PAZ_Y_JUSTICIA_INFO",
data: {
nombre,
email,
mensaje,
senderName : "Centro del Reino de Paz y Justicia",
},
}),
});
if (!emailResponse.ok) {
console.error("Error enviando correo");
return new Response(
JSON.stringify({ error: "Error en servicio de correo" }),
{ status: 500 }
); );
}
return new Response(null, { return new Response(null, {
status: 302, status: 302,