/** * Trigger the worker tick endpoint locally. * * Reads `CRON_SECRET` from `.env` (loaded by Node's --env-file when run via * `pnpm jobs:tick`) and GETs /api/jobs/run with the matching * `Authorization: Bearer …` header — the same shape Vercel Cron sends. * * In production, Vercel Cron does this automatically; this script is the * local equivalent. */ import process from 'node:process' const url = process.env.JOBS_TICK_URL ?? 'http://127.0.0.1:3000/api/jobs/run' const secret = process.env.CRON_SECRET if (!secret) { console.error('CRON_SECRET not set; copy from .env or run `pnpm gen:cron-secret`') process.exit(1) } const response = await fetch(url, { method: 'GET', headers: { authorization: `Bearer ${secret}` }, }) const body = await response.text() if (!response.ok) { console.error(`worker tick failed with ${response.status}: ${body}`) process.exit(1) } console.log(body)