Remix
import type { ActionFunctionArgs } from "@remix-run/node";
import { json } from "@remix-run/node";
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!}` } }
);
if (!r.ok) return false;
const data = await r.json();
return data.is_disposable === true;
} catch {
return false;
}
}
export async function action({ request }: ActionFunctionArgs) {
const formData = await request.formData();
const email = formData.get("email");
if (await isDisposable(String(email))) {
return json({ error: "Please use a real email address." }, { status: 400 });
}
// ...signup logic
return json({ ok: true });
}Notes
Add `DG_KEY` to your `.env` file. The check runs on the server in the action function.