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:
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user