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

React app env vars #6

Merged
merged 3 commits into from
Aug 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildpacks
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
https://github.com/heroku/heroku-buildpack-nodejs.git
https://github.com/mars/create-react-app-inner-buildpack.git#v1.1.0
https://github.com/mars/create-react-app-inner-buildpack.git#v1.2.0
https://github.com/heroku/heroku-buildpack-static.git
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ Eventually, to share, collaborate, or simply back-up your code, [create an empty
Customization
-------------

### Web server

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

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

### Routing clean URLs
#### Routing clean URLs

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`.

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

### Environment variables

`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.

Set [config vars on a Heroku app](https://devcenter.heroku.com/articles/config-vars) like this:

```bash
heroku config:set REACT_APP_HELLO='I love sushi!'
```

♻️ 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.

```bash
git commit --allow-empty -m "Set REACT_APP_HELLO config var"
git push heroku master
```

Version compatibility
---------------------

Expand Down