<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ibrahim M. Badr</title>
    <description>The latest articles on DEV Community by Ibrahim M. Badr (@ibrahimbdr).</description>
    <link>https://dev.to/ibrahimbdr</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F996727%2F34191a6f-1547-472e-8959-0cc298e61e6f.jpeg</url>
      <title>DEV Community: Ibrahim M. Badr</title>
      <link>https://dev.to/ibrahimbdr</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ibrahimbdr"/>
    <language>en</language>
    <item>
      <title>Your Cloudflare Turnstile may never be issuing a token — here is the one-liner that tells you</title>
      <dc:creator>Ibrahim M. Badr</dc:creator>
      <pubDate>Wed, 18 Nov 2026 22:33:10 +0000</pubDate>
      <link>https://dev.to/ibrahimbdr/your-cloudflare-turnstile-may-never-be-issuing-a-token-here-is-the-one-liner-that-tells-you-4h75</link>
      <guid>https://dev.to/ibrahimbdr/your-cloudflare-turnstile-may-never-be-issuing-a-token-here-is-the-one-liner-that-tells-you-4h75</guid>
      <description>&lt;p&gt;I was writing browser-QA automation and kept hitting contact forms where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the Turnstile widget was in the DOM and marked rendered,&lt;/li&gt;
&lt;li&gt;its challenge iframe request returned HTTP 200,&lt;/li&gt;
&lt;li&gt;and &lt;code&gt;cf-turnstile-response&lt;/code&gt; stayed empty. Forever.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That is not a bot check failing. It is no token being issued at all, which means &lt;strong&gt;no real user can&lt;br&gt;
submit that form either&lt;/strong&gt; — and nothing in the page throws.&lt;/p&gt;

&lt;p&gt;Paste this in devtools on any page with a Turnstile widget:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;widgets&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelectorAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'.cf-turnstile'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;token&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'input[name="cf-turnstile-response"]'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="o"&gt;?&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;widgets: 1, token: 0&lt;/code&gt; after 15 seconds means you are in this state. I reproduced it on a live site&lt;br&gt;
in both headless and headed Chrome, with a real (non-automated) user agent.&lt;/p&gt;

&lt;p&gt;The two causes I found, in order of likelihood:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The sitekey is not bound to that hostname&lt;/strong&gt; (staging key on production, or an allowed-domains
list that does not include the apex/www variant you actually serve).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The form never calls &lt;code&gt;reset()&lt;/code&gt;&lt;/strong&gt; after a failed submit. Turnstile tokens are single-use; a retry
without reset leaves the field empty and the backend rejects it as if you were a bot.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A related thing worth knowing if you test such forms: Cloudflare's documented &lt;strong&gt;test sitekey&lt;/strong&gt;&lt;br&gt;
&lt;code&gt;1x00000000000000000000AA&lt;/code&gt; mints a token with zero interaction, so you can exercise the widget on&lt;br&gt;
staging without a solver and without touching production keys. The token is only accepted end to end&lt;br&gt;
if the backend verifies with the matching test secret &lt;code&gt;1x0000000000000000000000000000000AA&lt;/code&gt; — that is&lt;br&gt;
the part people forget, and swapping production keys to make a test pass is how you ship a hole.&lt;/p&gt;

&lt;p&gt;If you want the whole procedure (detect → read the token → the test-key path → the line you do not&lt;br&gt;
cross on sites you do not own), it is in the &lt;code&gt;live-qa&lt;/code&gt; skill of the collection I published:&lt;br&gt;
github.com/Appit-labs/live-qa — MIT, works in Claude Code, Codex, pi and Cursor.&lt;/p&gt;

&lt;p&gt;Not a solver. It will not bypass anything on a site you do not own, and it says so in the skill.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>security</category>
      <category>cloudflare</category>
      <category>testing</category>
    </item>
    <item>
      <title>Using Token with next-auth</title>
      <dc:creator>Ibrahim M. Badr</dc:creator>
      <pubDate>Mon, 26 Dec 2022 19:35:10 +0000</pubDate>
      <link>https://dev.to/ibrahimbdr/using-token-with-next-auth-kki</link>
      <guid>https://dev.to/ibrahimbdr/using-token-with-next-auth-kki</guid>
      <description>&lt;p&gt;I am building a website by next js and I choose next-auth to handle login and protecting the routes, I managed to do the login in logic, but in order to be able to use post method to my api I need to send the token to my backend which I handled the related route (Backend done by NodeJS). The issue is that I can't reach the token and use it in the header in my requests. &lt;/p&gt;

</description>
      <category>bitcoin</category>
      <category>cryptocurrency</category>
      <category>cybersecurity</category>
    </item>
  </channel>
</rss>
