Skip to content
This repository has been archived by the owner on Jun 11, 2022. It is now read-only.

Need to Re-deploy after setting Env Vars #178

Closed
s2t2 opened this issue Sep 27, 2020 · 3 comments
Closed

Need to Re-deploy after setting Env Vars #178

s2t2 opened this issue Sep 27, 2020 · 3 comments

Comments

@s2t2
Copy link

s2t2 commented Sep 27, 2020

Hi, thanks for this great buildpack. It has really made deploying react apps much easier!

However, I am experiencing some behavior possibly related to this issue, where a re-deploy is required AFTER setting REACT_APP_ env vars in order for them to be recognized on Heroku.

Steps to reproduce:

  1. Add some code to your react app which references and prints an env var, like var API_URL = process.env.REACT_APP_API_URL || "http://localhost:5000".
  2. Then commit and deploy the code to heroku via git push heroku master.
  3. Then set the env var via heroku config:set REACT_APP_API_URL="my-api-url"
  4. When you visit the site, you'll see it not recognize the env var.

After re-deploying again AFTER setting the env var, you'll see it works.

Desired behavior:

When I set an env var on Heroku, perhaps the build should be re-triggered or something, so a re-deploy is not necessary.

Version:

I believe I'm using the most recent version of this buildpack, but not sure how to check. This is the output from heroku buildpacks:versions mars/create-react-app:

Version  Released At               Status
───────  ────────────────────────  ─────────
7        2019-03-11T14:43:39.712Z  published
6        2018-12-23T16:31:59.674Z  published
5        2018-10-08T20:48:34.131Z  published
4        2018-10-02T16:59:42.585Z  published
3        2018-09-23T20:00:49.383Z  published
2        2018-09-11T18:31:36.419Z  published
1        2018-05-30T18:32:49.395Z  published
@mars
Copy link
Owner

mars commented Sep 29, 2020

Did you try using the Runtime Environment Variables feature?

@mars mars closed this as completed Oct 1, 2020
@s2t2
Copy link
Author

s2t2 commented Oct 1, 2020

I see. However to stay consistent with the normal Heroku environment variable experience, I recommend that any setting of REACT_APP environment variables will trigger a re-build. Is that possible?

@mars
Copy link
Owner

mars commented Oct 1, 2020

Sorry @s2t2 no, that's not possible from the buildpack perspective.

There are ways you could probably finagle behavior like that:

  • use a custom webhook processor to trigger rebuilds
    • trade-off: additional custom async service complexity to create/maintain your custom release behavior
  • always rebuild on dyno start-up by putting your JS build command in .profile
    • trade-off: slow dyno start-up times which will timeout after 60secs.

Neither of those is "normal Heroku" and each has massive trade-off.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants