mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-08-03 11:07:00 -04:00
12 lines
472 B
TypeScript
12 lines
472 B
TypeScript
export const validateCaptcha = async (token: string): Promise<boolean> => {
|
|
const res = await fetch('https://challenges.cloudflare.com/turnstile/v0/siteverify', {
|
|
method: 'POST',
|
|
headers: {
|
|
'content-type': 'application/x-www-form-urlencoded',
|
|
},
|
|
body: `response=${encodeURIComponent(token)}&secret=${encodeURIComponent(process.env.TURNSTILE_SECRET!)}`,
|
|
});
|
|
const body = await res.json();
|
|
return body.success;
|
|
};
|