Let's talk about what you're shipping.
++ Tell us about your project and we'll get back to you shortly. +
++ Send us a message +
+ {status === "success" ? ( +
+
+ Tell us about your project and we'll get back to you shortly. +
+
+
Name: ${escapeHtml(name)}
+ Email: ${escapeHtml(email)}
+ Subject: ${escapeHtml(subject)}
${escapeHtml(message)}
+ ++ Reply to this email to answer ${escapeHtml(name)} directly. +
+ + +`; +} + +export async function POST(request: NextRequest) { + try { + const body = await request.json(); + const input = contactSchema.parse(body); + + if (input.website) { + // Pretend success so bots don't retry. + return NextResponse.json( + { success: true, message: "Thanks — we'll be in touch soon." }, + { status: 200 } + ); + } + + if (!process.env.RESEND_API_KEY) { + if (process.env.NODE_ENV !== "production") { + console.warn( + "[contact] RESEND_API_KEY missing — dev no-op for:", + input.email + ); + return NextResponse.json( + { success: true, message: "Dev mode: message logged, not sent." }, + { status: 200 } + ); + } + return NextResponse.json( + { success: false, message: "Contact form temporarily unavailable." }, + { status: 503 } + ); + } + + const resend = getResend(); + + const { error } = await resend.emails.send({ + from: + process.env.RESEND_FROM_EMAIL ?? "Concepta