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

Commit 45797dc

Browse files
authored
Merge pull request #6 from mars/react-app-env-vars
React app env vars
2 parents 4c7b922 + 62f5a76 commit 45797dc

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

.buildpacks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
https://github.com/heroku/heroku-buildpack-nodejs.git
2-
https://github.com/mars/create-react-app-inner-buildpack.git#v1.1.0
2+
https://github.com/mars/create-react-app-inner-buildpack.git#v1.2.0
33
https://github.com/heroku/heroku-buildpack-static.git

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ Eventually, to share, collaborate, or simply back-up your code, [create an empty
8080
Customization
8181
-------------
8282

83+
### Web server
84+
8385
The web server may be [configured via the static buildpack](https://github.com/heroku/heroku-buildpack-static#configuration).
8486

8587
The default `static.json`, if it does not exist in the repo, is:
@@ -88,7 +90,7 @@ The default `static.json`, if it does not exist in the repo, is:
8890
{ "root": "build/" }
8991
```
9092

91-
### Routing clean URLs
93+
#### Routing clean URLs
9294

9395
By default, [React Router](https://github.com/reactjs/react-router) (not included) uses hash-based URLs like `https://example.com/index.html#/users/me/edit`. This is nice & easy when getting started with local development, but for a public app you probably want real URLs like `https://example.com/users/me/edit`.
9496

@@ -104,6 +106,23 @@ Create a `static.json` file to configure the web server for clean [`browserHisto
104106
}
105107
```
106108

109+
### Environment variables
110+
111+
`REACT_APP_*` [custom environment variables](https://github.com/facebookincubator/create-react-app/blob/v0.2.3/template/README.md#adding-custom-environment-variables) are supported on Heroku.
112+
113+
Set [config vars on a Heroku app](https://devcenter.heroku.com/articles/config-vars) like this:
114+
115+
```bash
116+
heroku config:set REACT_APP_HELLO='I love sushi!'
117+
```
118+
119+
♻️ The app must be re-deployed for this change to take effect, because the normal app restart does not rebuild the React app with the new values.
120+
121+
```bash
122+
git commit --allow-empty -m "Set REACT_APP_HELLO config var"
123+
git push heroku master
124+
```
125+
107126
Version compatibility
108127
---------------------
109128

0 commit comments

Comments
 (0)