demo: turnstile challenge widget
a small contact-form-shaped page with cloudflare turnstile guarding submit. the widget issues a short-lived token in the browser; the pages function calls turnstile's siteverify api server-side before accepting the form.
# form
complete the challenge and submit…
# how it works
- widget loads from
challenges.cloudflare.com, runs a browser challenge - on pass, injects a token into a hidden
cf-turnstile-responseinput - form posts that token to
/api/turnstile-verify - function calls
https://challenges.cloudflare.com/turnstile/v0/siteverifywith the secret + token - if
success: true, form is accepted
# config
| widget name | SITE_turnstile_demo |
| mode | managed (cloudflare picks the challenge) |
| site key | 0x4AAAAAAEJgSPTwbmt7L0ea (public) |
| secret key | TURNSTILE_SECRET_KEY (pages env var, encrypted) |
| verify endpoint | /api/turnstile-verify |