This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Zaimki/server/captcha.js

14 lines
452 B
JavaScript
Raw Normal View History

2021-08-07 03:03:49 -07:00
import fetch from 'node-fetch';
export const validateCaptcha = async (token) => {
const res = await fetch('https://hcaptcha.com/siteverify', {
method: 'POST',
headers: {
'content-type': 'application/x-www-form-urlencoded',
},
body: `response=${encodeURIComponent(token)}&secret=${encodeURIComponent(process.env.HCAPTCHA_SECRET)}`
});
const body = await res.json();
return body['success'];
}