0

I am using google recaptcha v2. Client side works perfectly and generates token tha i pass to server in order to validate.

I make the api call to google using that token and in response i get gibberish (res.data is gibberis), here is a snippet of my code which makes the api call,

const payload = {
        secret: process.env.NEXT_PUBLIC_RECAPTCHA_SECRET_KEY ?? "",
        response: reCaptchaValue,
        remoteip: undefined,
    };
 const verifyResponse = await axios({
            method: "POST",
            url: `https://www.google.com/recaptcha/api/siteverify`,
            data: payload,
            headers: {
                "Content-Type": "application/json",
            },
        });

is there anything wrong with my call?

I tried various ways of making a post call using axios, but i get same response. if i use the url and paste it in my browser i get nice response but don't get any from here.

Cory Kramer
  • 114,268
  • 16
  • 167
  • 218

0 Answers0