import { NextRequest, NextResponse } from "next/server"; import { scanInbox } from "@/lib/email-watcher"; export async function GET(request: NextRequest) { if (!process.env.CRON_SECRET) { return NextResponse.json({ error: "CRON_SECRET not configured" }, { status: 500 }); } const authHeader = request.headers.get("authorization"); if (authHeader !== `Bearer ${process.env.CRON_SECRET}`) { return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); } const result = await scanInbox(); return NextResponse.json(result); }