Include commit URLs in VERCEL_RELATED_PROJECTS and deployment webhooks for monorepo E2E testing

Problem

When using Related Projects in a monorepo with two apps (e.g., api and ui), it’s difficult to run E2E tests against commit-specific preview deployments due to URL mismatches.

Current behavior:

  1. The VERCEL_RELATED_PROJECTS environment variable only includes the branch URL for preview deployments, not the commit-specific URL:
{
  "preview": {
    "branch": "my-app-git-feature-branch-team.vercel.app"
  }
}
  1. The vercel.deployment.success repository_dispatch webhook event_payload only includes the commit URL, not the branch URL:
{
  "url": "https://my-app-a1b2c3d4-team.vercel.app"
}

The issue:

  • The api uses VERCEL_RELATED_PROJECTS to configure CORS, so it only allows the ui’s branch URL.
  • The GitHub workflow receives the commit URL from the webhook.
  • E2E tests running against the commit URL fail CORS because only the branch URL is allowed.
  • Commit URLs cannot be derived between projects (different deployment IDs despite same git SHA).
  • Branch URLs cannot be derived in the GitHub Action from the payload.

Proposed Solution

  1. Add branchUrl to the repository_dispatch payload:
{
  "url": "https://my-app-a1b2c3d4-team.vercel.app",
  "branchUrl": "https://my-app-git-feature-branch-team.vercel.app"
}
  • This would enable testing against the branch URL, if wanted.
  1. Add commit (commit URL) to VERCEL_RELATED_PROJECTS for preview:
{
  "preview": {
    "branch": "my-app-git-feature-branch-team.vercel.app",
    "commit": "my-app-a1b2c3d4-team.vercel.app"
  }
}
  • This would help to setup the correct CORS URL and each ui commit would run against the related commit URL of the backend (preventing version/commit mismatch).

Use Case

Running E2E tests in CI against commit-specific preview deployments in a monorepo where the frontend needs to communicate with a related api project, and CORS must be correctly configured.

Thank you for considering this!