mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 04:22:12 +00:00
[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:
5
.changeset/silver-items-retire.md
Normal file
5
.changeset/silver-items-retire.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@vercel/build-utils": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Fix `getPrefixedEnvVars()` to handle `VERCEL_BRANCH_URL`
|
||||||
@@ -14,7 +14,12 @@ export function getPrefixedEnvVars({
|
|||||||
envs: Envs;
|
envs: Envs;
|
||||||
}): Envs {
|
}): Envs {
|
||||||
const vercelSystemEnvPrefix = 'VERCEL_';
|
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 = {};
|
const newEnvs: Envs = {};
|
||||||
if (envPrefix && envs.VERCEL_URL) {
|
if (envPrefix && envs.VERCEL_URL) {
|
||||||
Object.keys(envs)
|
Object.keys(envs)
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ describe('Test `getPrefixedEnvVars()`', () => {
|
|||||||
envs: {
|
envs: {
|
||||||
VERCEL: '1',
|
VERCEL: '1',
|
||||||
VERCEL_URL: 'example.vercel.sh',
|
VERCEL_URL: 'example.vercel.sh',
|
||||||
|
VERCEL_ENV: 'production',
|
||||||
|
VERCEL_BRANCH_URL: 'example-git-main-acme.vercel.app',
|
||||||
USER_ENV_VAR_NOT_VERCEL: 'example.com',
|
USER_ENV_VAR_NOT_VERCEL: 'example.com',
|
||||||
VERCEL_ARTIFACTS_TOKEN: 'abc123',
|
VERCEL_ARTIFACTS_TOKEN: 'abc123',
|
||||||
FOO: 'bar',
|
FOO: 'bar',
|
||||||
@@ -20,6 +22,8 @@ describe('Test `getPrefixedEnvVars()`', () => {
|
|||||||
},
|
},
|
||||||
want: {
|
want: {
|
||||||
NEXT_PUBLIC_VERCEL_URL: 'example.vercel.sh',
|
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_',
|
TURBO_CI_VENDOR_ENV_KEY: 'NEXT_PUBLIC_VERCEL_',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user