swyxio / gatsby-netlify-form-example-v2

Home Page:https://gatsby-netlify-form-example-v2.netlify.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GATSBY_ prefix on Recaptcha

gixxerblade opened this issue · comments

The README.md states "Important: the environment variables need to be called SITE_RECAPTCHA_KEY and SITE_RECAPTCHA_SECRET for the Netlify backend to find them. If you add a GATSBY_ prefix to the variable names, the Netlify backend won't recognize them, the reCAPTCHA verification will fail, and your form submissions won't be stored."
Your L6 references the GATSBY_ prefix. Is it needed or not?

const RECAPTCHA_KEY = process.env.GATSBY_APP_SITE_RECAPTCHA_KEY
if (typeof RECAPTCHA_KEY === 'undefined') {
  throw new Error(`
  Env var GATSBY_APP_SITE_RECAPTCHA_KEY is undefined! 
  You probably forget to set it in your Netlify build environment variables. 
  Make sure to get a Recaptcha key at https://www.netlify.com/docs/form-handling/#custom-recaptcha-2-with-your-own-settings
  Note this demo is specifically for Recaptcha v2
  `)
}

https://github.com/sw-yx/gatsby-netlify-form-example-v2/blob/6058403077f35a58f21df00af2eb0f185f7b5c9a/src/pages/recaptcha.js#L6

heh, it looks like i cheated and double posted:

image

probably should update the readme