---
title: "Stop bots"
description: "Check that a person, not a script, asks for a sign-in code or creates an account: Vercel BotID on Vercel, a Turnstile challenge elsewhere, and verifyHuman for your own calls."
canonical_url: "https://nuxt-backend.dev/docs/build/auth/sign-in/bots"
---
# Stop bots

> Check that a person, not a script, asks for a sign-in code or creates an account: Vercel BotID on Vercel, a Turnstile challenge elsewhere, and verifyHuman for your own calls.

Version: nuxt-backend 0.6.x · Tab: Build · Kind: how-to · Status: stable

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

- [API reference](https://nuxt-backend.dev/docs/reference/api/use-human-check)
- [Source](https://github.com/qruto/nuxt-backend/blob/main/src/convex/integrations/functions.ts)

Every request that sends a sign-in code is an email against your sending reputation, and every sign-up is an account. Rate limits bound how fast one address or one client can go. Bot protection checks that a person makes the request at all. It is the `protection` [capability](https://nuxt-backend.dev/docs/start/concepts/capabilities), always on: what runs depends on where the app runs and on the keys you set.

Vercel BotID and Cloudflare Turnstile do the checking. Better Auth's captcha plugin verifies a Turnstile answer natively. The package adds the proof that carries a BotID verdict to your Convex deployment, wires both into the sign-in form, and gives your own functions the same check through `useHumanCheck` and `verifyHuman`. Creating the keys and setting them is on [Bot protection](https://nuxt-backend.dev/docs/services/bot-protection).

## What it protects

The auth route that sends a sign-in code, wherever it is called from: `useLoginFlow`, `<AuthForm>`, the "Confirm it's you" dialog, or your own call to the auth client.

<table>
<thead>
  <tr>
    <th>
      Route, under the auth route
    </th>
    
    <th>
      What it does
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        /email-otp/send-verification-otp
      </code>
    </td>
    
    <td>
      Sends a sign-in code. Sign-up starts here too.
    </td>
  </tr>
</tbody>
</table>

Checking a code, passkeys and every signed-in route are left out: none of them sends mail, and each has [limits](https://nuxt-backend.dev/docs/ship/security/rate-limits) of its own. Your own functions are protected with [`verifyHuman`](#protect-your-own-calls).

## On Vercel: BotID

An invisible check, with nothing to click and nothing to show. A build on Vercel turns BotID on in the browser and on the server. BotID's client checks each protected request before it leaves the browser, and the Nuxt server checks the result with `checkBotId()` before the auth proxy forwards it. A bot is refused there.

Production needs `PROTECTION_PROOF_SECRET` on the deployment and on the Vercel project; [Bot protection](https://nuxt-backend.dev/docs/services/bot-protection#generate-the-proof-secret) sets it up, with BotID's plans and Deep Analysis.

Only Vercel signs proofs. Off Vercel no bot check runs on the Nuxt server, so use the [challenge](#with-a-site-key-a-turnstile-challenge) there.

### Why the deployment checks a proof

Better Auth runs on the deployment, at its own public URL (`https://<deployment>.convex.site`). The Nuxt server's auth proxy is the way in for your pages, but not the only one: anyone can call the deployment's URL directly and skip BotID. So once BotID passes, the Nuxt server signs a proof into the request it forwards, and the deployment refuses a protected route without one that passes:

- **The proof** is `v1.<time>.<signature>` in the `x-backend-proof` header: an HMAC-SHA-256, under `PROTECTION_PROOF_SECRET`, of the request's method and path, the address its body names, the deployment it goes to and the time it was signed.
- **It is accepted for a minute**, for that route, that address and that deployment only. A proof for one route or address never passes for another, an old one is refused, and one signed for another deployment is refused whatever secret the two share.
- **The caller never writes it.** The Nuxt server drops any `x-backend-proof` a request arrives with before its own check runs.

A proof can be used again within its minute, for the same route and the same address. That address's own limits bound what that buys a bot.

## With a site key: a Turnstile challenge

Off Vercel, BotID can't run, so the browser answers a Cloudflare Turnstile challenge and the deployment verifies it. [Bot protection](https://nuxt-backend.dev/docs/services/bot-protection#elsewhere) sets up the widget and its two keys.

Each protected request then carries the challenge's answer in the `x-captcha-response` header, which Better Auth's captcha plugin verifies with Cloudflare before the route runs. The widget stays out of sight unless Cloudflare asks for a click. Then it shows at the foot of the page, under "Confirm you're a person to continue." (the `auth.challenge` label), and takes the focus until it is answered. Restyle it through its hook, `[data-backend-challenge]` (`data-interactive` while it asks). The module lets `https://challenges.cloudflare.com` into the security headers' `script-src` and `frame-src`.

A site key holds on Vercel too: the browser answers the challenge there as well, and BotID still checks the same requests. A deployment with both secrets takes either.

`useLoginFlow`, `<AuthForm>` and the auth client's own calls answer the challenge for you. An app that points `convex.betterAuth.authClient` at an auth client of its own sends the answer in the `x-captcha-response` header of each protected request. Where the app's server signs no proof, `useHumanCheck().token('sign-in')` gets one.

## Protect your own calls

A vote on a public strip, a form on your landing page or any other call of your own reaches the deployment over the live connection, never through the Nuxt server. Ask for a token in the browser with `useHumanCheck()`, pass it with the call, and check it in an action with `verifyHuman`. The package's own [waitlist](https://nuxt-backend.dev/docs/build/growth/launch/waitlist) join does this for you.

```vue [app/components/StripVote.vue]
<script setup lang="ts">
import { api } from '#backend/api'

const props = defineProps<{ stripId: string }>()
const vote = useAction(api.votes.cast)
const { token } = useHumanCheck()

async function submit() {
  await vote({ stripId: props.stripId, human: await token('vote', props.stripId) })
}
</script>
```

```ts [backend/votes.ts]
import { verifyHuman } from 'nuxt-backend/functions'
import { v } from 'convex/values'
import { internal } from './_generated/api'
import { action, internalMutation } from './_generated/server'

export const cast = action({
  args: { stripId: v.id('strips'), human: v.optional(v.union(v.string(), v.null())) },
  handler: async (ctx, { stripId, human }) => {
    await verifyHuman(ctx, human, { action: 'vote', subject: stripId })
    await ctx.runMutation(internal.votes.record, { stripId })
  },
})

export const record = internalMutation({
  args: { stripId: v.id('strips') },
  handler: async (ctx, { stripId }) => {
    await ctx.db.insert('votes', { stripId })
  },
})
```

- **On Vercel**, `token(action, subject)` asks the Nuxt server's `/api/human-proof` route, which runs BotID and answers with a proof signed for that action, that subject and the deployment. A proof passes in a query or a mutation too.
- **With a site key off Vercel**, the token is the challenge's answer, given for that action. Verifying it takes a request to Cloudflare, which Convex allows in actions only. That is why the check above runs in an action, which works on every host. A query or mutation that calls `verifyHuman` takes proofs only, so it works on Vercel alone.
- **With neither secret on the deployment**, `verifyHuman` lets every call through, and `token` may answer `null`.

An action name is up to 32 letters, digits, `_` and `-`: a token given for `vote` never passes for `contact`. A subject is optional, up to 320 characters and read without case: a proof given for one strip or address never passes for another.

A proof for a call that names no subject is bound to the browser instead. The route sets an HttpOnly visitor cookie the first time (`__Host-` over HTTPS, signed with `PROTECTION_PROOF_SECRET`), signs the proof for that visitor, and `verifyHuman` hands the visitor to [`jobs.enqueue`](https://nuxt-backend.dev/docs/build/ai/jobs/guests) in the same mutation, which is how a signed-out visitor starts a guest job.

## In development

Outside production, the dev server's bot check answers human without asking, as BotID itself does in development. The deployment checks nothing until a secret is set.

To run the proof path on your machine, put a `PROTECTION_PROOF_SECRET` in `.env.local` and run `npx nuxt-backend env push`. The dev server signs a proof into each protected request, and the dev deployment checks it.

To try the challenge, use Cloudflare's test keys. The site key `1x00000000000000000000AA` with the secret key `1x0000000000000000000000000000000AA` always passes. `2x00000000000000000000AB` with `2x0000000000000000000000000000000AA` always fails, which is how to see a refusal on your machine. A production that runs on them fails `doctor --prod`.

## What happens when…

<table>
<thead>
  <tr>
    <th>
      Refused with
    </th>
    
    <th>
      When
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/backend/errors#forbidden">
        <code>
          forbidden
        </code>
      </a>
      
      , reason <code>
        bot_check
      </code>
    </td>
    
    <td>
      The check failed, or a protected request arrived without a proof or an answer. The person reads "We couldn't confirm you're a person. Try again."
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        forbidden
      </code>
      
      , reason <code>
        bot_check
      </code>
      
       from <code>
        verifyHuman
      </code>
    </td>
    
    <td>
      Your own call carried no token, or one given for another action or subject.
    </td>
  </tr>
</tbody>
</table>

A deployment that takes proofs and no challenge answer refuses every sign-in code request off Vercel. The Nuxt server warns once when it holds the secret off Vercel, and so does `doctor --prod`.

## Limits

- **BotID runs only on Vercel.** Elsewhere, the Turnstile challenge is the check.
- **A proof lives a minute** and can be reused within it for the same route and address.
- **Turnstile's answer is verified in an action**, so `verifyHuman` with a challenge answer needs an action. Queries and mutations take proofs only.
- **Deep Analysis** costs extra on Vercel Pro ([Bot protection](https://nuxt-backend.dev/docs/services/bot-protection)).

## Test it

Check it against the deployment, then see a refusal with Cloudflare's always-fail keys:

```bash
npx nuxt-backend doctor --only protection
```

- `bot-protection` says what the deployment checks. Under `--prod` it warns when nothing does.
- `protection-proof` signs a proof with the secret in your env and sends the deployment an empty code request with it. It sends no mail and spends no limit. Two different secrets, or a site URL that isn't the deployment's own, fail.
- `protection-challenge-keys` fails when the deployment asks for a challenge answer and the app shows no widget, or when production runs on the test keys.

Every finding is on the [diagnostics page](https://nuxt-backend.dev/docs/reference/cli/diagnostics#bot-protection).

## Related

- [Bot protection](https://nuxt-backend.dev/docs/services/bot-protection): creating the keys, and where each one goes.
- [Sign users in](https://nuxt-backend.dev/docs/build/auth/sign-in): the form the check guards.
- [Tune rate limits](https://nuxt-backend.dev/docs/ship/security/rate-limits): the limits on code requests and passkey challenges.
- [Capabilities](https://nuxt-backend.dev/docs/reference/capabilities): the `protection` capability and how its state is detected.


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
