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:
@ -1,10 +1,11 @@
|
||||
import type { APIRoute } from 'astro';
|
||||
import {
|
||||
getEmailBinding,
|
||||
getNewsletterDb,
|
||||
getRuntimeEnv,
|
||||
readEnv,
|
||||
required,
|
||||
sendWithResend,
|
||||
sendCloudflareEmail,
|
||||
type NewsletterSubscriber,
|
||||
} from '../../../lib/newsletter';
|
||||
|
||||
@ -57,9 +58,7 @@ export const GET: APIRoute = async ({ request, locals, url }) => {
|
||||
.bind(row.id)
|
||||
.run();
|
||||
|
||||
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);
|
||||
@ -67,10 +66,9 @@ export const GET: APIRoute = async ({ request, locals, url }) => {
|
||||
readEnv('NEWSLETTER_NOTIFY_TO_EMAIL', runtimeEnv) ||
|
||||
readEnv('CONTACT_FORM_TO_EMAIL', runtimeEnv);
|
||||
|
||||
if (resendApiKey && fromEmail && notifyTo) {
|
||||
if (emailBinding && fromEmail && notifyTo) {
|
||||
try {
|
||||
await sendWithResend({
|
||||
apiKey: resendApiKey,
|
||||
await sendCloudflareEmail(emailBinding, {
|
||||
fromEmail,
|
||||
toEmail: notifyTo,
|
||||
subject: 'Iscrizione newsletter confermata — NexStudio',
|
||||
|
||||
Reference in New Issue
Block a user