Skip to content

Commit 7886e53

Browse files
committed
fix: add API key validation for Resend initialization in contact form
1 parent fada052 commit 7886e53

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

apps/website/app/api/contact/route.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import type { NextRequest } from "next/server";
22
import { NextResponse } from "next/server";
33
import { Resend } from "resend";
44

5-
const resend = new Resend(process.env.RESEND_API_KEY || "");
6-
75
interface ContactFormData {
86
inquiryType: "support" | "sales" | "other";
97
name: string;
@@ -14,6 +12,17 @@ interface ContactFormData {
1412

1513
export async function POST(request: NextRequest) {
1614
try {
15+
// Initialize Resend with API key check
16+
const apiKey = process.env.RESEND_API_KEY;
17+
if (!apiKey) {
18+
console.error("RESEND_API_KEY is not configured");
19+
return NextResponse.json(
20+
{ error: "Email service not configured" },
21+
{ status: 500 },
22+
);
23+
}
24+
25+
const resend = new Resend(apiKey);
1726
const body: ContactFormData = await request.json();
1827

1928
// Validate required fields

0 commit comments

Comments
 (0)