Sostituisce Resend con Cloudflare Email Service.

Usa il binding EMAIL per contatti e newsletter, eliminando la dipendenza da Resend e dalle relative API key.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Javaxman
2026-07-29 09:54:12 +02:00
parent 2b470c778a
commit 0743521d48
9 changed files with 97 additions and 93 deletions

View File

@ -1,10 +1,11 @@
import type { APIRoute } from 'astro';
import {
absoluteUrl,
getEmailBinding,
getNewsletterDb,
getRuntimeEnv,
readEnv,
sendWithResend,
sendCloudflareEmail,
siteOrigin,
type NewsletterSubscriber,
} from '../../../../lib/newsletter';
@ -73,15 +74,13 @@ export const POST: APIRoute = async ({ request, locals, url }) => {
});
}
const resendApiKey =
readEnv('NEWSLETTER_RESEND_API_KEY', runtimeEnv) ||
readEnv('CONTACT_FORM_RESEND_API_KEY', runtimeEnv);
const emailBinding = getEmailBinding(runtimeEnv);
const fromEmail =
readEnv('NEWSLETTER_FROM_EMAIL', runtimeEnv) ||
readEnv('CONTACT_FORM_FROM_EMAIL', runtimeEnv);
if (!resendApiKey || !fromEmail) {
return new Response('Missing Resend API key or from email for newsletter send.', {
if (!emailBinding || !fromEmail) {
return new Response('Missing EMAIL binding or from email for newsletter send.', {
status: 500,
});
}
@ -129,8 +128,7 @@ export const POST: APIRoute = async ({ request, locals, url }) => {
: undefined;
try {
await sendWithResend({
apiKey: resendApiKey,
await sendCloudflareEmail(emailBinding, {
fromEmail,
toEmail: subscriber.email,
subject,