funktechnik-schubert-website/app/api/contact/route.ts
2026-07-03 19:14:34 +02:00

25 lines
794 B
TypeScript

import { NextResponse } from "next/server";
function text(value: FormDataEntryValue | null) {
return typeof value === "string" ? value.trim() : "";
}
export async function POST(request: Request) {
const form = await request.formData();
const name = text(form.get("name"));
const email = text(form.get("email"));
const message = text(form.get("message"));
if (!name || !email.includes("@") || message.length < 10 || form.get("privacy") !== "on") {
return NextResponse.json({ message: "Bitte füllen Sie alle Pflichtfelder aus." }, { status: 400 });
}
console.info("contact_request.received", {
messageLength: message.length,
hasEmail: true,
});
return NextResponse.json({
message: "Ihre Nachricht wurde erfasst. Sie erhalten eine Rückmeldung.",
});
}