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:
- The
VERCEL_RELATED_PROJECTSenvironment variable only includes the branch URL for preview deployments, not the commit-specific URL:
{
"preview": {
"branch": "my-app-git-feature-branch-team.vercel.app"
}
}
- The
vercel.deployment.successrepository_dispatchwebhookevent_payloadonly includes the commit URL, not the branch URL:
{
"url": "https://my-app-a1b2c3d4-team.vercel.app"
}
The issue:
- The
apiusesVERCEL_RELATED_PROJECTSto configureCORS, so it only allows theui’s branch URL. - The GitHub workflow receives the commit URL from the webhook.
- E2E tests running against the commit URL fail
CORSbecause 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
- Add
branchUrlto therepository_dispatchpayload:
{
"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.
- Add
commit(commit URL) toVERCEL_RELATED_PROJECTSfor 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
CORSURL and eachuicommit 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!