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 Jun 11, 2022. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+24Lines changed: 24 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,7 @@ Deploy React.js web apps generated with [create-react-app](https://github.com/fa
15
15
*[Web server](#web-server)
16
16
*[Routing clean URLs](#routing-clean-urls)
17
17
*[HTTPS-only](#https-only)
18
+
*[Proxy](#proxy)
18
19
*[Environment variables](#environment-variables)
19
20
*[Set vars on Heroku](#set-vars-on-heroku)
20
21
*[Set vars for local dev](#set-vars-for-local-dev)
@@ -174,6 +175,29 @@ Prevent downgrade attacks with [HTTP strict transport security](https://develope
174
175
175
176
*`max-age` is the number of seconds to enforce HTTPS since the last connection; the example is 90-days
176
177
178
+
### Proxy
179
+
180
+
Proxy XHR requests from the React UI in the browser to API backends. Prevent same-origin errors when [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS) is not available on the backend.
181
+
182
+
Configure using [Proxy Backends from the static site buildpack](https://github.com/heroku/heroku-buildpack-static/blob/master/README.md#proxy-backends). Add `"proxies"` to `static.json`:
183
+
184
+
```json
185
+
{
186
+
"proxies": {
187
+
"/api/": {
188
+
"origin": "${API_URL}"
189
+
}
190
+
}
191
+
}
192
+
```
193
+
194
+
Then, point the React UI app to a specific backend API:
[`REACT_APP_*` environment variables](https://github.com/facebookincubator/create-react-app/blob/v0.2.3/template/README.md#adding-custom-environment-variables) are supported with this buildpack.
0 commit comments