import { NextRequest, NextResponse } from "next/server"; import { Resend } from "resend"; const resend = new Resend(process.env.RESEND_API_KEY); export async function POST(req: NextRequest) { try { const { email, name } = await req.json(); if (!email) { return NextResponse.json({ error: "Email required" }, { status: 400 }); } const { data, error } = await resend.emails.send({ from: "ClauseGuard ", to: [email], subject: "Welcome to ClauseGuard", html: `

Welcome to ClauseGuard${name ? `, ${name}` : ""}

You now have a tool that reads the fine print for you. Here is what you can do:

Scan your first document

You are receiving this because you signed up at clauseguardweb.netlify.app.

`, }); if (error) { return NextResponse.json({ error: error.message }, { status: 500 }); } return NextResponse.json({ id: data?.id }); } catch (error) { console.error("Email error:", error); return NextResponse.json({ error: "Failed to send email" }, { status: 500 }); } }