mirror of
https://github.com/Dokploy/website.git
synced 2026-06-15 20:25:25 +02:00
fix: add API key validation for Resend initialization in contact form
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user