You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 13, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+33-9Lines changed: 33 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -311,9 +311,9 @@ Replace `http://localhost:8000` with the URL to your local or remote backend ser
311
311
312
312
### Environment variables
313
313
314
-
[`REACT_APP_*` environment variables](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-custom-environment-variables) are supported with this buildpack.
314
+
[`REACT_APP_*` environment variables](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-custom-environment-variables) are fully supported with this buildpack.
315
315
316
-
🤐 *Be careful not to export secrets. These values may be accessed by anyone who can see the React app.*
316
+
🚫🤐 ***Not for secrets.** These values may be accessed by anyone who can see the React app.*
317
317
318
318
### [Set vars on Heroku](https://devcenter.heroku.com/articles/config-vars)
Use Node's [`process.env` object](https://nodejs.org/dist/latest-v10.x/docs/api/process.html#process_process_env).
355
+
356
+
```javascript
357
+
importReact, { Component } from'react';
358
+
359
+
classAppextendsComponent {
360
+
render() {
361
+
return (
362
+
<code>Runtime env var example: { process.env.REACT_APP_HELLO }</code>
363
+
);
364
+
}
365
+
}
366
+
```
367
+
368
+
♻️ The app must be re-deployed for compiled changes to take effect, because during the build, these references will be replaced with their quoted string value.
Only `REACT_APP_` vars are replaced in create-react-app's build. To make any other variables visible to React, they must be prefixed for the build command in `package.json`, like this:
Supports only [`REACT_APP_`](https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-custom-environment-variables) prefixed variables.
386
+
387
+
🚫🤐 ***Not for secrets.** These values may be accessed by anyone who can see the React app.*
364
388
365
389
Install the [runtime env npm package](https://www.npmjs.com/package/@mars/heroku-js-runtime-env):
🤐 *Be careful not to export secrets. These values may be accessed by anyone who can see the React app.*
434
+
🚫🤐 ***Be careful not to export secrets.** These values may be accessed by anyone who can see the React app.*
411
435
412
-
Use a custom [`.profile.d` script](https://devcenter.heroku.com/articles/buildpack-api#profile-d-scripts) to make variables visible to the React app by prefixing them with `REACT_APP_`.
436
+
Use a custom [`.profile.d` script](https://devcenter.heroku.com/articles/buildpack-api#profile-d-scripts) to make variables set by other components available to the React app by prefixing them with `REACT_APP_`.
413
437
414
438
1. create `.profile.d/000-react-app-exports.sh`
415
439
1. make it executable `chmod +x .profile.d/000-react-app-exports.sh`
@@ -476,10 +500,10 @@ This buildpack will never intentionally cause previously deployed apps to become
476
500
[Releases are tagged](https://github.com/mars/create-react-app-buildpack/releases), so you can lock an app to a specific version, if that kind of determinism pleases you:
0 commit comments