<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Cloudflare on ps4bp</title><link>https://ps4bp.netlify.app/tags/cloudflare/</link><description>Recent content in Cloudflare on ps4bp</description><generator>Hugo</generator><language>en-US</language><lastBuildDate>Tue, 27 Oct 2026 11:45:01 +1100</lastBuildDate><atom:link href="https://ps4bp.netlify.app/tags/cloudflare/index.xml" rel="self" type="application/rss+xml"/><item><title>Cloudflare Turnstile</title><link>https://ps4bp.netlify.app/posts/cloudflare-turnstile/</link><pubDate>Tue, 27 Oct 2026 11:45:01 +1100</pubDate><guid>https://ps4bp.netlify.app/posts/cloudflare-turnstile/</guid><description>&lt;h1 id="put-a-gate-in-a-worker"&gt;&#10; Put a gate in a worker&#10; &lt;a class="heading-link" href="#put-a-gate-in-a-worker"&gt;&#10; &lt;i class="fa-solid fa-link" aria-hidden="true" title="Link to heading"&gt;&lt;/i&gt;&#10; &lt;span class="sr-only"&gt;Link to heading&lt;/span&gt;&#10; &lt;/a&gt;&#10;&lt;/h1&gt;&#10;&lt;ol&gt;&#10;&lt;li&gt;Create a Turnstile widget.&#10;&lt;img src="https://ps4bp.netlify.app/images/cloudflare-turnstile-1.png" alt="Cloudflare Turnstile 1 "&gt;&#10;&#10;In the Cloudflare dashboard, open Turnstile → Add &lt;code&gt;worker-captcha&lt;/code&gt; &lt;em&gt;manually&lt;/em&gt;. Add &lt;a href="https://forex-proxy.ps4bp.workers.dev" class="external-link" target="_blank" rel="noopener"&gt;forex-proxy.ps4bp.workers.dev&lt;/a&gt; as an allowed hostname and copy the sitekey and secret key. The sitekey is public; keep the secret private.&lt;/li&gt;&#10;&lt;li&gt;Store the keys as Worker variables.&#10;&lt;img src="https://ps4bp.netlify.app/images/cloudflare-turnstile-2.png" alt="Cloudflare Turnstile 2"&gt;&#10;&#10;In Workers &amp;amp; Pages → forex-proxy → Settings → Runtime variables and Secrets, add:&#10;&lt;ul&gt;&#10;&lt;li&gt;&lt;code&gt;TURNSTILE_SITE_KEY&lt;/code&gt; as a regular text variable.&lt;/li&gt;&#10;&lt;li&gt;&lt;code&gt;TURNSTILE_SECRET_KEY&lt;/code&gt; as a secret.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;Make the Worker handle requests before serving the page.&#10;Have it:&#10;&lt;ul&gt;&#10;&lt;li&gt;Check for a valid pass cookie on each page request.&lt;/li&gt;&#10;&lt;li&gt;If there isn’t one, return a small HTML verification page containing the Turnstile widget.&lt;/li&gt;&#10;&lt;li&gt;Accept the widget token at a verification endpoint and send it to &lt;a href="https://challenges.cloudflare.com/turnstile/v0/siteverify" class="external-link" target="_blank" rel="noopener"&gt;https://challenges.cloudflare.com/turnstile/v0/siteverify&lt;/a&gt;.&lt;/li&gt;&#10;&lt;li&gt;Only after Siteverify returns success: true, issue a short-lived, signed pass cookie and redirect back to /.&lt;/li&gt;&#10;&lt;li&gt;Serve index.html when the cookie is valid.&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;/li&gt;&#10;&lt;li&gt;Protect every route that should be gated.&#10;If only the landing page needs protection, gate /. If API routes also need protection, gate those separately so the verification endpoint stays reachable.&lt;/li&gt;&#10;&lt;li&gt;Deploy and check both paths.&#10;Test that a fresh browser sees the challenge, a successful verification reaches the page, and a request without a valid cookie cannot fetch the protected content directly.&lt;/li&gt;&#10;&lt;/ol&gt;</description></item></channel></rss>