backend/utils/captcha.js

15 lines
386 B
JavaScript
Raw Normal View History

2023-03-03 16:44:40 +00:00
const fetch = require('node-fetch')
async function checkCaptcha(response) {
2023-03-03 18:17:39 +00:00
const confirm = await (await fetch('https://hcaptcha.com/siteverify', {
2023-03-03 16:44:40 +00:00
method: 'POST',
body: new URLSearchParams({
'response': response,
'secret': process.env.CAPTCHA_SECRET
})
})).json()
return confirm.success
}
module.exports = { checkCaptcha }