23 lines
769 B
TypeScript
23 lines
769 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import { requireAdmin } from "@/lib/api-auth";
|
|
import { sendEmail, verifyEmailHtml } from "@/lib/email";
|
|
|
|
export async function POST(req: NextRequest) {
|
|
const { response } = await requireAdmin();
|
|
if (response) return response;
|
|
|
|
const { to } = await req.json() as { to: string };
|
|
if (!to) return NextResponse.json({ error: "Missing 'to'" }, { status: 400 });
|
|
|
|
try {
|
|
await sendEmail({
|
|
to,
|
|
subject: "Epicure — test email",
|
|
html: verifyEmailHtml(`${process.env["BETTER_AUTH_URL"] ?? "http://localhost:3001"}/verify-email?token=test`),
|
|
});
|
|
return NextResponse.json({ ok: true });
|
|
} catch (err) {
|
|
return NextResponse.json({ error: String(err) }, { status: 500 });
|
|
}
|
|
}
|