This commit is contained in:
2026-04-03 14:09:06 -04:00
parent f8f59a5134
commit fe94d4c543
5 changed files with 19 additions and 8 deletions

View File

@@ -1,4 +1,5 @@
import type { APIRoute } from 'astro';
import { env } from 'cloudflare:workers';
import { sendEmail } from '@/lib/email';
import general from '@/content/settings/general.json';
@@ -70,7 +71,7 @@ function buildContactNotificationHtml(data: ContactBody): string {
</html>`;
}
export const POST: APIRoute = async ({ request, locals }) => {
export const POST: APIRoute = async ({ request }) => {
let body: unknown;
try {
body = await request.json();
@@ -88,8 +89,7 @@ export const POST: APIRoute = async ({ request, locals }) => {
});
}
const runtime = (locals as { runtime?: { env?: Record<string, string> } }).runtime;
const apiKey = runtime?.env?.RESEND_API_KEY;
const apiKey = (env as unknown as Record<string, string>).RESEND_API_KEY;
const toAddress = general.emailToContact?.trim();
const fromAddress = general.emailFromContact?.trim();
if (!apiKey || !toAddress || !fromAddress) {