feat: implement fire-and-forget background email sending for instant API response
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
3c46684b1b
commit
d002516bc8
@@ -311,7 +311,17 @@ export const POST: APIRoute = async ({ request, clientAddress }) => {
|
||||
|
||||
// Fire-and-forget: send email in background so the user gets an instant response.
|
||||
// Errors are logged/reported but never block the HTTP reply.
|
||||
const recipientEmail = process.env.CONTACT_EMAIL_TO || 'unknown';
|
||||
console.log('Sending contact email to: ' + recipientEmail);
|
||||
|
||||
sendContactEmail(formData).catch(async (err) => {
|
||||
console.error('Background email delivery failed:', {
|
||||
recipient: recipientEmail,
|
||||
email: formData.email,
|
||||
subject: formData.subject,
|
||||
error: err instanceof Error ? err.message : String(err),
|
||||
stack: err instanceof Error ? err.stack : undefined,
|
||||
});
|
||||
logger.error('api.contact', 'Background email delivery failed', {
|
||||
email: formData.email,
|
||||
subject: formData.subject,
|
||||
@@ -334,7 +344,7 @@ export const POST: APIRoute = async ({ request, clientAddress }) => {
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
success: true,
|
||||
message: "Message received! We'll get back to you within 24 hours.",
|
||||
message: 'Your message has been received. We will get back to you soon.',
|
||||
}),
|
||||
{ status: 200, headers: rateLimitHeaders }
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user