[build-utils] Fix getPrefixedEnvVars() to handle VERCEL_BRANCH_URL (#10315)

- Fixes [NEXT-1500](https://linear.app/vercel/issue/NEXT-1500)
- See
[documentation](https://vercel.com/docs/concepts/projects/environment-variables/system-environment-variables#framework-environment-variables)
This commit is contained in:
Steven
2023-08-08 14:43:20 -04:00
committed by GitHub
parent 2995781a58
commit a8ecf40d6f
3 changed files with 15 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
"@vercel/build-utils": patch
---
Fix `getPrefixedEnvVars()` to handle `VERCEL_BRANCH_URL`

View File

@@ -14,7 +14,12 @@ export function getPrefixedEnvVars({
envs: Envs;
}): Envs {
const vercelSystemEnvPrefix = 'VERCEL_';
const allowed = ['VERCEL_URL', 'VERCEL_ENV', 'VERCEL_REGION'];
const allowed = [
'VERCEL_URL',
'VERCEL_ENV',
'VERCEL_REGION',
'VERCEL_BRANCH_URL',
];
const newEnvs: Envs = {};
if (envPrefix && envs.VERCEL_URL) {
Object.keys(envs)

View File

@@ -13,6 +13,8 @@ describe('Test `getPrefixedEnvVars()`', () => {
envs: {
VERCEL: '1',
VERCEL_URL: 'example.vercel.sh',
VERCEL_ENV: 'production',
VERCEL_BRANCH_URL: 'example-git-main-acme.vercel.app',
USER_ENV_VAR_NOT_VERCEL: 'example.com',
VERCEL_ARTIFACTS_TOKEN: 'abc123',
FOO: 'bar',
@@ -20,6 +22,8 @@ describe('Test `getPrefixedEnvVars()`', () => {
},
want: {
NEXT_PUBLIC_VERCEL_URL: 'example.vercel.sh',
NEXT_PUBLIC_VERCEL_ENV: 'production',
NEXT_PUBLIC_VERCEL_BRANCH_URL: 'example-git-main-acme.vercel.app',
TURBO_CI_VENDOR_ENV_KEY: 'NEXT_PUBLIC_VERCEL_',
},
},