staging #75
|
|
@ -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,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue