Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jun 11, 2022. It is now read-only.

Commit 7af9344

Browse files
authored
📚 revs to Proxy & Testing sections
1 parent 5fbc974 commit 7af9344

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

‎README.md‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,13 @@ Eventually, to share, collaborate, or simply back-up your code, [create an empty
142142

143143
### Testing
144144

145-
Use [create-react-app's built-in Jest testing](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#user-content-running-tests) or whatever testing library you prefer.
145+
Use [create-react-app's built-in Jest testing](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#user-content-running-tests) or whatever testing library you prefer.
146146

147-
As long as tests can be run with `npm test` (like the built-in Jest testing) then it will work effortlessly with [Heroku CI](https://devcenter.heroku.com/articles/heroku-ci).
147+
[Heroku CI](https://devcenter.heroku.com/articles/heroku-ci) is supported with minimal configuration. The CI integration is compatible with npm & yarn (see [`bin/test`](bin/test)).
148148

149149
#### Minimal `app.json`
150150

151-
Heroku CI uses [`app.json`](https://devcenter.heroku.com/articles/app-json-schema) to provision test apps. To enable Heroku CI, commit this minimal example `app.json`:
151+
Heroku CI uses [`app.json`](https://devcenter.heroku.com/articles/app-json-schema) to provision test apps. To support Heroku CI, commit this minimal example `app.json`:
152152

153153
```json
154154
{
@@ -231,7 +231,21 @@ Prevent downgrade attacks with [HTTP strict transport security](https://develope
231231

232232
### Proxy
233233

234-
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.
234+
Proxy XHR requests from the React UI in the browser to API backends. Use to prevent same-origin errors when [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS) is not supported on the backend.
235+
236+
#### Proxy URL prefix
237+
238+
To make calls through the proxy, use relative URL's in the React app which will be proxied to the configured target URL. For the example URL prefix of `/api/`, here's how the proxy would rewrite the requests:
239+
240+
```
241+
/api/search-items
242+
→ https://backend.example.com/search-items
243+
244+
/api/users/me
245+
→ https://backend.example.com/users/me
246+
```
247+
248+
You may choose any prefix and may have multiple proxies with different prefixes.
235249

236250
#### Proxy for deployment
237251

@@ -253,7 +267,7 @@ Add `"proxies"` to `static.json`:
253267
Then, point the React UI app to a specific backend API:
254268

255269
```bash
256-
heroku config:set API_URL="https://api.example.com"
270+
heroku config:set API_URL="https://backend.example.com"
257271
```
258272

259273
#### Proxy for local development
@@ -422,6 +436,7 @@ This buildpack composes several buildpacks (specified in [`.buildpacks`](.buildp
422436
* [Nginx](http://nginx.org/en/) web server
423437
* handy static website & SPA (single-page app) [customization options](https://github.com/heroku/heroku-buildpack-static#configuration)
424438

439+
Runtime processes are launched based on the last buildpack's [Procfile](#user-content-procfile).
425440

426441
### General-purpose SPA deployment
427442

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /