email contacto cloudflare
This commit is contained in:
parent
9aa0105fca
commit
5dc873580e
|
|
@ -1,5 +1,6 @@
|
|||
import type { APIRoute } from "astro";
|
||||
import { prisma } from "../lib/prisma";
|
||||
import { sendEmailCf } from "../lib/email";
|
||||
|
||||
export const prerender = false;
|
||||
|
||||
|
|
@ -64,32 +65,11 @@ export const POST: APIRoute = async ({ request }) => {
|
|||
},
|
||||
});
|
||||
}
|
||||
const emailApiKey = import.meta.env.EMAIL_API_KEY;
|
||||
|
||||
const emailResponse = await fetch("https://flows2.carpa.com/webhook/email/send", {
|
||||
method: "POST",
|
||||
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 }
|
||||
);
|
||||
}
|
||||
await sendEmailCf(
|
||||
{ nombre, email, mensaje },
|
||||
"joseperez@centrodelreinodepazyjusticia.com",
|
||||
"CENTRO_DEL_REINO_PAZ_Y_JUSTICIA_INFO",
|
||||
);
|
||||
|
||||
return new Response(null, {
|
||||
status: 302,
|
||||
|
|
|
|||
Loading…
Reference in New Issue