Home / patterns

Cron and webhook-style job endpoints anyone can trigger

Quick answer: AI-built apps often run scheduled jobs (send digests, charge renewals, sync data, clean up records) from a public URL like /api/cron/daily. If the route doesn't check a secret, anyone who finds the URL can run the job as often as they like: spamming your users, burning API credits or repeating payments.

Last updated November 11, 2026

Steps

  1. List every scheduled job: vercel.json "crons" entries, Supabase pg_cron or scheduled Edge Functions, GitHub Actions schedules, and any external pinger calling your app.
  2. On Vercel, add a CRON_SECRET environment variable (Vercel recommends a random string of at least 16 characters). Vercel then sends it as an Authorization: Bearer header when it calls your cron job.
  3. At the top of each job route, compare the Authorization header to Bearer + CRON_SECRET and return 401 if it doesn't match, before any work happens.
  4. For Supabase scheduled functions, keep the key or token in Supabase Vault as its docs show, not hard-coded in the SQL, and check it in the function.
  5. Make each job safe to run twice or to skip a run. Vercel's docs say cron delivery is best effort: a scheduled run can occasionally be missed or invoked more than once, and a long job can overlap with the next one. Use a lock or a "last processed" marker.
  6. Rename any job URL that has already been shared or logged, and rotate the secret if it ever appeared in client code or a public repo.

Why it matters

A cron route is just an HTTP endpoint. Vercel's cron documentation says to secure it with CRON_SECRET and check the Authorization header in your function. Without that check, the job is as public as your homepage.

Sources

Vercel Docs: Managing Cron Jobs (Securing cron jobs, idempotency, concurrency) — https://vercel.com/docs/cron-jobs/manage-cron-jobs

Supabase Docs: Scheduling Edge Functions — https://supabase.com/docs/guides/functions/schedule-functions

Related patterns

Found a problem you'd rather not fix yourself?

Tell us what's wrong. A StorenTech engineer reviews your app and replies with a fixed quote, so you know the cost before any work starts.

Get it fixed by StorenTech

Vibe Security Weekly

One email a week with new failure patterns and how to fix them.

By joining you agree we may email you this newsletter. See our privacy policy. Free. Unsubscribe anytime. We'll never sell your email.