Skip to content

Vercel

This page is for operators who deploy their own fork of Adiutor on Vercel. It covers what differs from other hosts, the databases and settings each environment needs, what vercel.json does, following releases, the background jobs, fork pull requests and rolling back.

  • No local disk for files. Choose an S3-compatible bucket or an SFTP folder: see File storage. The local folder storage is refused on Vercel.
  • Files up to 4 MB. Vercel refuses larger request bodies, so the largest file can’t be set above 4 MB.
  • Functions stop after 60 seconds.
  • The jobs need a schedule, because no process of yours keeps running. See Start the background jobs.
  • The client’s address works as it is. Vercel replaces X-Forwarded-For with the client’s address. See Reverse proxy.

Everything else is the same.

To set up:

  1. Fork the repository, and import your fork in Vercel.
  2. Add a database. Neon, through Vercel’s integration, works: it gives a pooled DATABASE_URL and a direct DATABASE_URL_UNPOOLED for migrations.
  3. Set the settings for each environment.
  4. Deploy. Each build migrates the database first (What vercel.json does).
  5. Follow First run right away, and start the background jobs.

Preview must never share Production’s database. Preview migrates on every build of main: sharing would put each migration into production before its release, and the live release would run against a schema it doesn’t know.

  • Turn on the Neon integration’s branch for preview deployments, or
  • connect the integration to Production only, create a preview branch in Neon, and set DATABASE_URL (pooled) and DATABASE_URL_UNPOOLED for Preview yourself.

Check that Preview’s database host differs from Production’s.

In Settings › Environment Variables, give each environment its own:

  • BETTER_AUTH_URL: the environment’s own address, or sign-in links and redirects point at the other one.
  • BETTER_AUTH_SECRET: a random secret of at least 32 characters.
  • CRON_SECRET: a different random secret per environment, at least 32 characters (openssl rand -base64 32), for the jobs’ endpoint.
  • Sign-in provider credentials, only where the callback addresses are registered with the provider: see Sign-in providers. Leave them unset in Preview otherwise.
  • The mail server and the file storage: see Email and File storage.

vercel.json is strict JSON, so it can’t hold comments. Its build settings take precedence over the same fields in the project’s dashboard.

  • What’s built. Every commit on main is built, except one that changes only sites/ (the website and the guide, which Vercel doesn’t serve). On production, only a release commit is built (its first line starts with chore(main): release ). Every other branch is skipped.
  • Each build migrates first. On main and production, pnpm db:migrate runs before pnpm build, through DATABASE_URL_UNPOOLED or else DATABASE_URL. When migrating fails, the build fails and the previous deployment stays live.
  • A tick every 15 minutes. A Vercel schedule (jobs-tick, Vercel Schedules, in beta) calls GET /api/jobs, with Authorization: Bearer and the environment’s CRON_SECRET. On the Hobby plan it runs somewhere within each 15 minutes. It’s the fallback for the external cron service below. Preview’s copy starts inactive: leave it so. On the Pro plan you can change it to */5 * * * *, and the external service becomes optional.

To have Production follow releases and Preview follow main:

  1. In Settings › Environments › Production, set the Production branch to production. Until that branch exists, Production keeps its current deployment.

  2. In a checkout of your fork, fetch the releases’ tags from Adiutor’s repository, and push the release you want to your fork’s production branch:

    Terminal window
    git remote add upstream https://github.com/bastolen/adiutor.git
    git fetch upstream --tags
    git push origin v0.5.0^{commit}:refs/heads/production

    The tag points at the release commit (its first line starts with chore(main): release ), so vercel.json builds it. Write refs/heads/production in full: pushing a tag to a plain production would create a tag of that name the first time, not the branch. For a later release, push its tag the same way.

main is then Preview. A push of anything but a release commit to production is skipped, so a stray push never reaches production. Give main a fixed address under Settings › Domains, with Git Branch set to main.

Use an external cron service (such as cron-job.org), one entry per environment, every 5 minutes:

  • GET https://<the environment's address>/api/jobs
  • The header Authorization: Bearer <that environment's CRON_SECRET>
  • For Preview with Deployment Protection on, also the header x-vercel-protection-bypass with the secret from Settings › Deployment Protection › Protection Bypass for Automation. That secret also gives deployments VERCEL_AUTOMATION_BYPASS_SECRET, which the endpoint uses to continue a tick on itself, so a backlog doesn’t wait for the next tick.
  • Have the service warn you when the answer isn’t 200: a 500 means a job failed.

Logs › Jobs then shows a recent tick. After 45 minutes without one, the dashboard and the Jobs page warn staff Admins and Managers that background jobs aren’t running. See Background jobs.

Keep Git Fork Protection on (Project Settings › Git). A fork brings its own vercel.json, so nothing else can stop its builds. Never authorise the deployment of a fork’s pull request: it would run with the Preview environment’s secrets.

Use Vercel’s Instant Rollback. A rolled-back deployment runs against the database as the newer release left it, so check Upgrading before you rely on it.

For https://adiutor.dev as Production and a Preview at its own address, each has its own Neon branch, its own CRON_SECRET, and its own cron entry calling /api/jobs every 5 minutes.

  • A failed migration keeps the previous deployment live: look at the build log.
  • Files are never on Vercel’s disk: set the storage before turning attachments on.

Adiutor's code is released under the MIT License. The Adiutor name and logo aren’t covered by it; see the notice.

Set in Inter and JetBrains Mono, under the SIL Open Font License (Inter, JetBrains Mono).