I have a code in Nodejs server which is using google recaptcha V3 to login a user. It's working perfectly with https://localhost:4000/
but for some wired reason it doesn't work with my example.com website ?!
any suggestion to debug this?
I have added both localhost and example.com to the list of google recaptcha console.
the code pauses before fetch, not going further seems like there is something wrong with fetch???
function login(req, res, next) {
const secret_key = config.recaptchaSecretKey;
const token = req.body.token;
const url = `https://www.google.com/recaptcha/api/siteverify?secret=${secret_key}&response=${token}`;
// the code pauses here not going further seems like there is something wrong with fetch???
fetch(url, {
method: 'post'
})
.then(response => response.json())
.then(google_response => {
if(!google_response.success || google_response.score < 0.4) {
return res.json({ success: false, error: "captcha verification failed" });
}
accountService.login(req.body)
.then(result => {
res.json(result);
})
.catch(next);
})
.catch(error => res.json({ error }));
}