The website is about to ask each browser to pass Cloudflare Turnstile. A
widget token proves nothing until siteverify confirms it, and the secret
that call needs cannot live in the page - so the page posts the token here
and gets a yes or no. That answer is ALL this produces: no cookie, no
session, nothing stored. The pages are prerendered and served without the
Worker, and docs/ToS.md section 9 promises that /api/data/*, /img/* and the
packaged apps are never human-checked, so nothing on the server could or
may require a pass.
- Same-origin only: POST, Origin equal to the request's own, Sec-Fetch-Site
(when sent) same-origin, JSON. No CORS - the apps never run the check.
- The body is read from the stream with a 4 KB cap, because a chunked
request carries no Content-Length; the JSON is parsed locally because a
SyntaxError message would quote the token into the logs.
- siteverify gets the secret, the token and CF-Connecting-IP, with an 8 s
timeout. The action ("enter", shared/human-check.ts, one definition for
both halves) and the hostname must match, except under Cloudflare's
published TEST secrets, whose answers are fixed ("localhost", "test").
- Statuses are chosen for the page, which refuses only on a verdict: 403
when Cloudflare said no; 503 without TURNSTILE_SECRET, so deploy order
never matters, or when a test widget's fixed token meets the real secret
(the site served on a hostname the widget does not know); 502 when
siteverify is unreachable, failing or garbled.
- Never logs the token or the IP; the tests spy on console to hold that.
TURNSTILE_SECRET is declared required in env.d.ts (an optional declaration
would clash with what `wrangler types` emits once .dev.vars defines it) and
checked at runtime. web/.dev.vars.example carries Cloudflare's always-pass
test secret for `wrangler dev`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
12 lines
686 B
Plaintext
12 lines
686 B
Plaintext
# Local secrets for `wrangler dev` - copy to .dev.vars (gitignored) and edit.
|
|
# Production secrets are set with `npx wrangler secret put <NAME>` and never
|
|
# appear in this repository.
|
|
|
|
# Cloudflare Turnstile's published ALWAYS-PASS test secret, not a real one.
|
|
# The web app renders the matching always-pass test widget on any hostname
|
|
# other than free-steam-games.win, so the human check can be exercised end to
|
|
# end on localhost. Swap in 2x0000000000000000000000000000000AA (always fails)
|
|
# or 3x0000000000000000000000000000000AA (token already spent) to see the
|
|
# refusal path; delete the line to see the "not configured" path.
|
|
TURNSTILE_SECRET=1x0000000000000000000000000000000AA
|