mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-27 00:04:37 +08:00
16 lines
496 B
JavaScript
16 lines
496 B
JavaScript
import fetch from "node-fetch";
|
|
import "dotenv/config";
|
|
|
|
export async function verify(captcha) {
|
|
if (process.env.MODE === "dev") return true;
|
|
const response = await fetch(
|
|
`https://www.google.com/recaptcha/api/siteverify`,
|
|
{
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
body: `secret=${process.env.RECAPTCHA_SECRET}&response=${captcha}`,
|
|
}
|
|
);
|
|
const responseJSON = await response.json();
|
|
return responseJSON?.success;
|
|
}
|