NEXT_PUBLIC_VERCEL_GIT_PULL_REQUEST_ID is empty in Preview
Answered
Bombay posted this in #help-forum
BombayOP
I'm trying to get the PR number during Preview, it returns empty string, it should return a number like the docs. I'm following this doc https://vercel.com/docs/concepts/projects/environment-variables/system-environment-variables
I confirm the
Do I miss something? Appreciate any hint. ðŸ™
I confirm the
Automatically expose System Environment Variables
is checked in Settings.Do I miss something? Appreciate any hint. ðŸ™
Answered by Bombay
OH it does not have PR ID on the first commit, it has to be the second commit.
5 Replies
BombayOP
I believe this is a bug. Other environment variables can show correctly:
-
-
-
only the
-
NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA
-
NEXT_PUBLIC_VERCEL_GIT_COMMIT_AUTHOR_LOGIN
-
NEXT_PUBLIC_VERCEL_GIT_COMMIT_AUTHOR_NAME
only the
NEXT_PUBLIC_VERCEL_GIT_PULL_REQUEST_ID
is incorrectthe code to generate that server url:
if (process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview') {
return `https://server-myproject-pr-${process.env.NEXT_PUBLIC_VERCEL_GIT_PULL_REQUEST_ID}.up.railway.app`;
}
BombayOP
OH it does not have PR ID on the first commit, it has to be the second commit.
Answer
Dwarf Crocodile
Hye @Bombay, I hit a similar problem. Do you happen to know if this is expected behavior, or a bug? I couldn't find anyone talking about it discord, reddit, or git...
BombayOP
If I remember correctly, it’s the expected limitation from Vercel. I will try to find the doc.