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

@ -100,34 +100,7 @@ export async function verifyTurnstile(
return payload.success === true;
}
export async function sendWithResend(options: {
apiKey: string;
fromEmail: string;
toEmail: string;
subject: string;
text: string;
html?: string;
}): Promise<void> {
const response = await fetch('https://api.resend.com/emails', {
method: 'POST',
headers: {
Authorization: `Bearer ${options.apiKey}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
from: options.fromEmail,
to: [options.toEmail],
subject: options.subject,
text: options.text,
...(options.html ? { html: options.html } : {}),
}),
});
if (!response.ok) {
const detail = await response.text();
throw new Error(`Resend error ${response.status}: ${detail}`);
}
}
export { getEmailBinding, sendCloudflareEmail } from './email';
export function siteOrigin(requestUrl: URL, runtimeEnv: RuntimeEnv): string {
const configured = readEnv('PUBLIC_SITE_URL', runtimeEnv) || readEnv('SITE', runtimeEnv);