Environment Variables in Pages Projects


I was seeing a 401 from the API I was trying to call from my Pages template because I forgot to add the API key to my branch environment variables. Once I added it, I saw that the api key was still undefined in the request. I then redeployed the same commit and still no luck. I finally had success once I rebuilt the project by pushing a new commit.

Is it accurate to say that when you add environment variables to a branch that you need to rebuild your project for it to get picked up?



Yes. A new build is required for branch environment variables to be picked up.

1 Like