diff --git a/apps/website/app/api/contact/route.ts b/apps/website/app/api/contact/route.ts index c9065d5..08ce38c 100644 --- a/apps/website/app/api/contact/route.ts +++ b/apps/website/app/api/contact/route.ts @@ -2,8 +2,6 @@ import type { NextRequest } from "next/server"; import { NextResponse } from "next/server"; import { Resend } from "resend"; -const resend = new Resend(process.env.RESEND_API_KEY || ""); - interface ContactFormData { inquiryType: "support" | "sales" | "other"; name: string; @@ -14,6 +12,17 @@ interface ContactFormData { export async function POST(request: NextRequest) { try { + // Initialize Resend with API key check + const apiKey = process.env.RESEND_API_KEY; + if (!apiKey) { + console.error("RESEND_API_KEY is not configured"); + return NextResponse.json( + { error: "Email service not configured" }, + { status: 500 }, + ); + } + + const resend = new Resend(apiKey); const body: ContactFormData = await request.json(); // Validate required fields