CAPTCHA support with Cloudflare Turnstile
Cloudflare Turnstile is a friendly, free CAPTCHA replacement, and it works seamlessly with Supra Edge Functions to protect your forms. View on GitHub.
Setup#
- Follow these steps to set up a new site: https://developers.cloudflare.com/turnstile/get-started/
- Add the Cloudflare Turnstile widget to your site: https://developers.cloudflare.com/turnstile/get-started/client-side-rendering/
Code#
Create a new function in your project:
_10supra functions new cloudflare-turnstile
And add the code to the index.ts file:
Deploy the server-side validation Edge Functions#
_10supra functions deploy cloudflare-turnstile_10supra secrets set CLOUDFLARE_TURNSTILE_SECRET_KEY=your_secret_key
Invoke the function from your site#
_10const { data, error } = await supra.functions.invoke('cloudflare-turnstile', {_10 body: { token },_10})