Guide

How to test sign-up and checkout on Vercel preview deployments

Every pull request on Vercel gets its own preview deployment: your real build, on a real URL, before anything reaches customers. It's the best place to check that sign-up and checkout still work. It's also where tests mysteriously fail with login pages, wrong redirects and live keys. This guide sets a preview up so tests can run against it safely, then runs them automatically.

Updated 6 min read

What a preview deployment is

By default Vercel creates a preview deployment when you push to any branch that isn't your production branch, open a pull request, or deploy from the CLI without --prod. Each one gets two URLs:

  • A commit URL (<project>-<hash>-<scope>.vercel.app) for that exact deployment. It changes on every push.
  • A branch URL (<project>-git-<branch>-<scope>.vercel.app) that always points at the branch's latest deployment. It stays the same as you push.

The Vercel bot comments on the pull request with a Visit Preview link (the branch URL). Tests should run against the commit URL, so they check exactly the code in that push.

1. Give previews their own keys

Vercel environment variables are set per environment: Production, Preview and Development. That's what keeps a test run from charging a real card or writing into your real database. In your project's Environment Variables settings, give the Preview environment:

  • Stripe test keys (sk_test_..., pk_test_...) and the test-mode webhook secret. Never the live ones.
  • A separate Supabase project (a free one is fine) for previews, so test sign-ups don't land among real users. Supabase Branching does this automatically per pull request on paid plans; a second project is the simple version.
  • A test account your tests can log in with, as TEST_USER_EMAIL and TEST_USER_PASSWORD, in that preview database.

Two gotchas from Vercel's docs: changes to environment variables only apply to new deployments (redeploy after editing), and a project's very first deployment always builds with Production variables. You can also scope a Preview variable to one branch; branch-specific values override the general Preview ones.

2. Let Supabase Auth redirect to preview URLs

Sign-up confirmation links, magic links and OAuth logins redirect back to your app. Supabase only redirects to URLs on its allow list, so on a preview they silently send people to your production site instead. Supabase's docs give the fix for Vercel: in Authentication, URL Configuration, keep your real domain as the Site URL and add these redirect URLs:

Text
http://localhost:3000/**
https://*-<your-team-or-account-slug>.vercel.app/**
* matches one part of a host name and ** matches any path. Use the exact path for production; the wildcards are for previews and local dev.

In your sign-up code, pass redirectTo built from the current deployment's URL (Supabase's docs show a getURL() helper using NEXT_PUBLIC_SITE_URL and NEXT_PUBLIC_VERCEL_URL). If your email templates use {{ .SiteURL }}, switch them to {{ .RedirectTo }} so the link follows the preview.

3. Get past Deployment Protection

Since late 2023, new Vercel projects protect deployments with Vercel Authentication by default. The recommended Standard Protection covers every deployment except your production domains, on all plans. Good for privacy, but an automated browser hitting your preview gets a Vercel login page (or a 401 or 403) instead of your app.

  1. Create a bypass secret

    In the project's Settings, Deployment Protection, under Protection Bypass for Automation, choose Create. Vercel also exposes it to your deployments as VERCEL_AUTOMATION_BYPASS_SECRET.

  2. Copy it into GitHub

    That variable exists inside the deployment, not in your CI. Add the same value as a repository secret named VERCEL_AUTOMATION_BYPASS_SECRET (Settings, Secrets and variables, Actions).

  3. Send it with the tests

    Vercel accepts it as an x-vercel-protection-bypass header (recommended) or query parameter. Adding x-vercel-set-bypass-cookie: true makes Vercel set a cookie so later navigations in the same test don't hit the login wall again.

TypeScript
import { defineConfig, devices } from "@playwright/test";

const bypass = process.env.VERCEL_AUTOMATION_BYPASS_SECRET;

export default defineConfig({
  testDir: "./tests",
  retries: process.env.CI ? 2 : 0,
  use: {
    baseURL: process.env.BASE_URL ?? "http://localhost:3000",
    extraHTTPHeaders: bypass ? { "x-vercel-protection-bypass": bypass, "x-vercel-set-bypass-cookie": "true" } : undefined,
    trace: "on-first-retry",
    screenshot: "only-on-failure",
  },
  projects: [{ name: "chromium", use: { ...devices["Desktop Chrome"] } }],
});
playwright.config.ts, following Vercel's documented Playwright setup.

4. Run the tests when the preview is ready

Vercel tells GitHub about each deployment through GitHub's deployment_status event, which a GitHub Actions workflow can listen for. Vercel's docs describe it as on by default, but we've seen new projects start with it off, so check: the switch is deployment_status Events in the project's Settings, Git. If your workflow never starts, that switch is the first suspect. Wait for the success state and use the deployment's URL:

YAML
name: Journeys on preview
on: deployment_status

jobs:
  journeys:
    # Only finished deployments, and only previews: these tests sign up and pay with test cards.
    if: github.event.deployment_status.state == 'success' && contains(github.event.deployment.environment, 'Preview')
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-node@v6
        with:
          node-version: lts/*
      - run: npm ci
      - run: npx playwright install --with-deps chromium
      - run: npx playwright test
        env:
          BASE_URL: ${{ github.event.deployment_status.environment_url }}
          VERCEL_AUTOMATION_BYPASS_SECRET: ${{ secrets.VERCEL_AUTOMATION_BYPASS_SECRET }}
          TEST_USER_EMAIL: ${{ secrets.TEST_USER_EMAIL }}
          TEST_USER_PASSWORD: ${{ secrets.TEST_USER_PASSWORD }}
      - uses: actions/upload-artifact@v4
        if: ${{ !cancelled() }}
        with:
          name: playwright-report
          path: playwright-report/
          retention-days: 30
.github/workflows/preview-journeys.yml. Check the environment names Vercel uses in your repo (they're listed under Environments on the repo's GitHub page) and adjust the contains(...) filter to match.

For this event the checked-out commit is the one that was deployed, so the tests always match the code on the preview. The result shows up as a check on the pull request.

Vercel also offers repository_dispatch events (such as vercel.deployment.success, with the URL in github.event.client_payload.url) and now encourages moving workflows to them; its knowledge base has a ready-made workflow (opens in a new tab). Both work. Two things to know if you switch: these workflows only run from your default branch, so check out github.event.client_payload.git.sha explicitly, and confirm in a test pull request that the event fires for your previews.

5. Stripe webhooks on previews

Checkout isn't finished until your webhook marks the order paid, so a full test needs Stripe's test-mode events to reach the preview. Three things get in the way:

  • The URL changes on every push. Register the stable branch URL (or a staging domain) as a test-mode webhook endpoint in Stripe, not a commit URL.
  • Deployment Protection blocks Stripe too. Vercel's docs show the case: append ?x-vercel-protection-bypass=YOUR_SECRET to the endpoint URL. Vercel warns that URLs get logged by proxies and servers, so keep this to test mode and a dedicated secret.
  • Each endpoint has its own signing secret (whsec_...). Put it in a Preview environment variable (scoped to that branch if needed) and redeploy.

Simpler for most teams: test the webhook handler locally with the Stripe CLI, and on previews test up to the redirect to Stripe Checkout. Our Stripe test mode guide covers both.

The checklist

  • Preview env vars use Stripe test keys and a separate Supabase project or branch.
  • Supabase redirect URLs include https://*-<slug>.vercel.app/**.
  • A Protection Bypass for Automation secret exists, and GitHub has a copy.
  • Playwright reads BASE_URL and sends the bypass.
  • A workflow runs on deployment_status success for previews only, and uploads the report.
  • Tests that create accounts or pay run only against previews, never production.

Where Corvis fits

Corvis runs your journeys on Vercel preview deployments without any of this wiring in your repo: it listens for the same deploy events, runs each journey in a real browser with the test account you give it (stored sealed), and posts a pass or fail on the pull request with a screenshot and a fix brief when something breaks. Journeys that change data run only on previews with Stripe test mode, and production checks are read-only. If deploy events stop arriving because that Vercel switch is off, Corvis says so on the pull request.

Sources

Checked against these pages on 24 October 2026. Providers change their dashboards; if a step looks different, the source has the current version.

  1. Vercel Docs: Environments (preview deployments) (opens in a new tab)
  2. Vercel Docs: Generated URLs (opens in a new tab)
  3. Vercel Docs: Environment variables (opens in a new tab)
  4. Vercel Docs: Deployment Protection (opens in a new tab)
  5. Vercel Docs: Protection Bypass for Automation (opens in a new tab)
  6. Vercel Docs: Automated agent access (opens in a new tab)
  7. Vercel Docs: Vercel for GitHub (deployment_status events) (opens in a new tab)
  8. Vercel KB: Run end-to-end tests after a preview deployment (opens in a new tab)
  9. Vercel changelog: Deployment Protection on by default for new projects (opens in a new tab)
  10. GitHub Docs: Events that trigger workflows (opens in a new tab)
  11. GitHub Docs: Deployment statuses (opens in a new tab)
  12. Supabase Docs: Redirect URLs (opens in a new tab)
  13. Supabase Docs: Branching (opens in a new tab)
  14. Stripe Docs: Webhooks (opens in a new tab)

Is your repo leaking right now?

The free scan checks a public GitHub repo for leaked keys and risky code, and grades it from A to F.

Scan a repo free