Worked example This website, built with AI coding tools
A contact form that looked fine but couldn't deliver
The keys were set and the form looked finished, yet nothing arrived. Two configuration problems, found by checking each link in the chain instead of rewriting code.
- Next.js, Resend, Cloudflare Turnstile
- Not a client project: a real problem from this site's own code
What happened
The project inquiry form on this site posts to a small API route, which checks for bots with Cloudflare Turnstile and sends the message through the email service Resend. Before launch it had to be proven to deliver, not just look like it does.
01
The problem
Sending the form showed "Your message couldn't be sent from here." The keys for the email service were in place, so on paper everything was configured.
02
The investigation
- Called the API directly, without a bot token. It answered "bot" instead of "off": the server could see its email settings, so the configuration was loaded.
- Watched the form in the browser. It never reached the API: the bot check failed first, with Turnstile error 110200. That means the page's domain isn't on the widget's list of allowed domains, and localhost wasn't.
- Sent one message through Resend with exactly the request the API route makes, from the same environment. Resend answered 403: the domain the mail was sent from was not verified.
03
The root cause
Two problems, neither of them in the code. The bot check only allowed the production domain, and the email service didn't yet trust the domain the mail came from. The code did what it should: it refused to pretend, and offered to send the message by email instead.
04
The decisions
- Kept the bot check on. Switching it off to make a local test pass would have hidden the real state of production.
- Tested the delivery step on its own, with the same request the route sends, instead of guessing from the form.
- Kept the honest failure message. A form that says "sent" when nothing was sent costs you leads you never hear about.
05
The fix
The domain was verified in Resend by adding its DNS records. The Turnstile limit was written down: the form can only be tested end to end on an allowed domain.
06
How it was checked
- The same request to Resend now returns 200, with a message id.
- The route's decisions have automated tests for every outcome: not configured, invalid input, bot, rate limit, a failed send and success.
What this means for your appWhen something fails, check each link in the chain before touching the code. Often the code is fine, and the problem is a setting in a dashboard somewhere.
Stuck on something like this? Tell me what your app should do and what goes wrong. I'll tell you what I would check first.
Get your app fixedAnother worked example: Link previews that quietly lost their image.