Spaces:
Sleeping
Sleeping
| 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 <welcome@clauseguardweb.netlify.app>", | |
| to: [email], | |
| subject: "Welcome to ClauseGuard", | |
| html: ` | |
| <div style="font-family:system-ui,sans-serif;max-width:480px;margin:0 auto;padding:40px 20px;"> | |
| <h1 style="font-size:20px;font-weight:600;color:#18181b;margin:0 0 16px;">Welcome to ClauseGuard${name ? `, ${name}` : ""}</h1> | |
| <p style="font-size:14px;color:#52525b;line-height:1.6;margin:0 0 24px;"> | |
| You now have a tool that reads the fine print for you. Here is what you can do: | |
| </p> | |
| <ul style="font-size:14px;color:#52525b;line-height:1.8;padding-left:20px;margin:0 0 24px;"> | |
| <li>Install the Chrome extension to scan pages as you browse</li> | |
| <li>Use the web scanner to paste and analyze any document</li> | |
| <li>Get a risk score and grade for every Terms of Service you encounter</li> | |
| </ul> | |
| <a href="https://clauseguardweb.netlify.app/dashboard-pages/analyze" | |
| style="display:inline-block;background:#18181b;color:#fff;padding:10px 20px;border-radius:6px;text-decoration:none;font-size:14px;font-weight:500;"> | |
| Scan your first document | |
| </a> | |
| <p style="font-size:12px;color:#a1a1aa;margin-top:32px;border-top:1px solid #f4f4f5;padding-top:16px;"> | |
| You are receiving this because you signed up at clauseguardweb.netlify.app. | |
| </p> | |
| </div> | |
| `, | |
| }); | |
| 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 }); | |
| } | |
| } | |