Heroku — update environment variable

Fred Wong
fredwong-it
Published in
2 min readDec 15, 2022

Learn something from setting up the environment variable in the heroku app today.

  1. Set the environment variable in dashboard

2. Restarting your app to clear the cache

3. Redeploy the app

Server side

step 1 and 2 will work and the value is updated in process.env.XXXXXX

Whenever you set or remove a config var using any method, your app is restarted

Client side

If step 1 and 2 doesn’t work, then we will need to trigger a re-build in step 3.

“environment variables” inside your app aren’t environment variables but are hardcoded. This can for instance happen when you build your project for a static app. Then it’ll use whatever environment variable that was set during build.

Therefore, restart app is different from rebuild app!

This is the answer from ChatGPT, it gives the same answer, interesting, nice!

Reference

--

--