0

I am attempting to verify recaptcha v3 using js and axios and I kept getting a CORS error. After looking up the 'Access-Controll-Allow-Origin' error, I read that you simply had to include either '*' or the site itself in the header.

const submitData = (token: any) => {
  axios
    .post(`https://www.google.com/recaptcha/api/siteverify`, {
      headers: {
        "Access-Control-Allow-Origin": "*",
      },
      params: {
        response: token,
        secret: SECRET,
      },
    })
    .then((res) => {
      setResponse(res.data);
    });
};

Above is my attempt to add the wildcard header. I keep receiving the "No 'Access-Control-Allow-Origin' header is present' error.

  • That header is to be emitted by the server, otherwise any client can just trivially circumvent CORS restrictions. – Terry Oct 12 '21 at 18:53

0 Answers0