Cloudflare tutor

A morning desk for Kotha · Gold Coast

· Australia/Brisbane · Lesson

Turnstile: stop bots on a form without a puzzle

Turnstile (Cloudflare's free CAPTCHA alternative for forms)

What it is

Turnstile is Cloudflare's replacement for the old "click all the traffic lights" CAPTCHA. You place a small widget on a web form. In the visitor's browser it runs quiet checks to decide whether a real person is there, and most people either see nothing or a single tick box. When the check passes, the widget hands the form a token, a long one-off string.

There are two keys. The site key is public and goes in your page so the widget knows which account it belongs to. The secret key stays on the server side, ideally as a Worker secret (lesson 5). When the form is submitted, your Worker sends the token and the secret key to Cloudflare's siteverify address, and Cloudflare replies yes or no. Only on a yes does the Worker save the message or send the email.

A token works once and expires after about five minutes, so a bot cannot copy one token and reuse it. You create widgets in the dashboard under Turnstile, choose which hostnames each widget may run on, and pick a mode: Managed (Cloudflare decides whether to show a tick box), Non-interactive (never asks the visitor to click), or Invisible (no visible widget at all). Turnstile does not need your site to be proxied, so it also works on pages hosted elsewhere, such as Vercel or Netlify.

Why it matters

Any public form, such as a contact form, a feedback box, or a sign-up page, attracts spam bots within days. Turnstile blocks most of them without making patients or colleagues solve picture puzzles, and it is free.

The check that matters happens on the server. A widget on the page alone stops nothing, because a bot can skip the page and post straight to your Worker. The siteverify call in the Worker is what actually rejects it.

It pairs well with what you already have: the WAF (lesson 13) blocks bad traffic for a whole hostname, while Turnstile guards one form button.

On your account

From your own setup: suppose one of your drkotha.com apps had a "Send feedback" form handled by a Worker. You would create one Turnstile widget for that hostname, paste the site key into the form's HTML, and store the secret key with wrangler secret put (for example as TURNSTILE_SECRET). The Worker would then check every submission with siteverify before writing it to D1 or emailing it to you, and quietly drop anything that fails.

A widget's hostname list keeps it tied to your own sites, so someone else cannot copy your site key onto their page and have it work.

This tutor has no forms and does not use Turnstile. Nothing in this lesson creates a widget or changes cloudflare-tutor, ainews, aiweekly, any redirect rule, or any other Worker or DNS record.

Do this yourself

These stay in the dashboard, on your side. This site does not change DNS, routes, or other Workers.

  1. In the Cloudflare dashboard, open Turnstile, start adding a widget, and write down the fields it asks for (widget name, hostnames, widget mode, and any pre-clearance option) before pressing Cancel. If you prefer to go one step further, save a widget named practice-form for one of your own subdomains in Managed mode and note where the site key and secret key are shown, but do not add it to any live page yet.