DisposableGuard

Next.js (App Router)

import { NextResponse } from 'next/server';

async function isDisposable(email: string) {
  try {
    const r = await fetch(
      `https://api.disposableguard.com/v1/check?email=${encodeURIComponent(email)}`,
      { headers: { Authorization: `Bearer ${process.env.DG_KEY!}` }, cache: 'no-store' }
    );
    if (!r.ok) return false;
    const data = await r.json();
    return data.is_disposable === true;
  } catch {
    return false;
  }
}

export async function POST(req: Request) {
  const { email, password } = await req.json();

  if (await isDisposable(email)) {
    return NextResponse.json(
      { error: 'Please use a real email address.' },
      { status: 400 }
    );
  }

  // ...your existing signup logic
  return NextResponse.json({ ok: true });
}

Notes

Add `DG_KEY=dg_live_...` to `.env.local`. Never expose the key in client-side code.