TinyShip
TinyShip
 TinyShip
TinyShip
TinyShip Documentation
TinyShip User GuideGetting StartedBasic Configuration
Credits System ConfigurationAffiliate System Configuration
Storage Service ConfigurationDatabase ConfigurationCaptcha Configuration
Development Best PracticesLocal E2E Workflow
User Guide

Captcha Configuration

Configure Cloudflare Turnstile on sign-in and sign-up

TinyShip uses Cloudflare Turnstile to block scripted sign-ups and sign-ins.

Related pages

PagePathDescription
Sign in/signinTurnstile when captcha is enabled
Sign up/signupTurnstile when captcha is enabled

Configuration

config/captcha.ts ships with captcha enabled. The provider id is 'cloudflare-turnstile'. Keys are read from the cloudflare getters.

// config/captcha.ts
import { getEnvForService } from './utils';

export const captchaConfig = {
  enabled: true,
  defaultProvider: 'cloudflare-turnstile',

  cloudflare: {
    get secretKey() {
      // Development always uses Cloudflare's pass-all test secret.
      if (process.env.NODE_ENV === 'development') {
        return '1x0000000000000000000000000000000AA';
      }
      return getEnvForService('TURNSTILE_SECRET_KEY', 'Cloudflare Turnstile');
    },
    get siteKey() {
      if (process.env.NODE_ENV === 'development') {
        return '1x00000000000000000000AA';
      }
      const publicKey = process.env.NEXT_PUBLIC_TURNSTILE_SITE_KEY;
      if (publicKey) return publicKey;
      return getEnvForService('TURNSTILE_SITE_KEY', 'Cloudflare Turnstile');
    },
  },
}
  • enabled turns verification on or off. Set it to false to skip Turnstile.
  • defaultProvider is 'cloudflare-turnstile'.
  • cloudflare.secretKey is the server secret (Better Auth).
  • cloudflare.siteKey is the public site key. In production it prefers NEXT_PUBLIC_TURNSTILE_SITE_KEY, then TURNSTILE_SITE_KEY.

Environment variables

# Cloudflare Turnstile
TURNSTILE_SECRET_KEY="your-turnstile-secret-key"
NEXT_PUBLIC_TURNSTILE_SITE_KEY="your-turnstile-site-key"

In development (NODE_ENV=development) those variables are not used. The getters return Cloudflare's always-pass test keys: site key 1x00000000000000000000AA and secret 1x0000000000000000000000000000000AA. Production needs the real keys from your Turnstile widget.

Create a Turnstile widget

  1. Open the Cloudflare dashboard.
  2. Go to Turnstile.
  3. Add a site (or open an existing widget).
  4. Copy the site key and the secret key into .env.

Database Configuration

Multi-dialect setup for PostgreSQL / SQLite / Cloudflare D1

Deployment

TinyShip deployment guide

On this page

Related pagesConfigurationEnvironment variablesCreate a Turnstile widget