Lead fehler

This commit is contained in:
Timo Knuth
2026-01-16 16:49:27 +01:00
parent af1c0456d7
commit 0eafe421d2
4 changed files with 49 additions and 0 deletions

View File

@@ -1,5 +1,6 @@
import { NextResponse } from 'next/server';
import { db } from '@/lib/db';
import { Prisma } from '@prisma/client';
interface LeadInput {
email: string;
@@ -37,6 +38,20 @@ export async function POST(request: Request) {
return NextResponse.json({ success: true, id: lead.id });
} catch (error) {
console.error('Error saving lead:', error);
if (error instanceof Prisma.PrismaClientKnownRequestError) {
if (error.code === 'P2021') {
console.error('CRITICAL: Table "Lead" does not exist in the database. Run "npx prisma migrate deploy" to fix this.');
return NextResponse.json(
{
error: 'Database configuration error',
details: 'Missing database table. Please run migrations.'
},
{ status: 500 }
);
}
}
// Return the actual error message for debugging purposes
return NextResponse.json(
{