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 ea2acbc

Browse files
authored
Default routing (#145)
1 parent f81fbdf commit ea2acbc

File tree

2 files changed

+22
-19
lines changed

2 files changed

+22
-19
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#v7.0.0
2+
https://github.com/mars/create-react-app-inner-buildpack.git#v8.0.0
33
https://github.com/heroku/heroku-buildpack-static.git

‎README.md‎

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Deploy React.js web apps generated with [create-react-app](https://github.com/fa
1717
* 👓 [Customization](#user-content-customization)
1818
* [Procfile](#user-content-procfile)
1919
* [Web server](#user-content-web-server)
20-
* [Routing clean URLs](#user-content-routing-clean-urls)
20+
* [Routing](#user-content-routing)
2121
* [HTTPS-only](#user-content-https-only)
2222
* [Proxy](#user-content-proxy)
2323
* [Environment variables](#user-content-environment-variables)
@@ -194,20 +194,6 @@ The config file `static.json` should be committed at the root of the repo. It wi
194194

195195
The default `static.json`, if it does not exist in the repo, is:
196196

197-
```json
198-
{ "root": "build/" }
199-
```
200-
201-
### Changing the root
202-
203-
If a different web server `"root"` is specified, such as with a highly customized, ejected create-react-app project, then the new bundle location may need to be [set to enable runtime environment variables](#user-content-custom-bundle-location).
204-
205-
### Routing clean URLs
206-
207-
[React Router](https://github.com/ReactTraining/react-router) (not included) may easily use 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`.
208-
209-
Create a `static.json` file at the root of the repo to configure the web server for clean [`browserHistory` with React Router v3](https://github.com/ReactTraining/react-router/blob/v3/docs/guides/Histories.md#browserhistory) & [`BrowserRouter` with v4](https://reacttraining.com/react-router/web/api/BrowserRouter):
210-
211197
```json
212198
{
213199
"root": "build/",
@@ -217,7 +203,15 @@ Create a `static.json` file at the root of the repo to configure the web server
217203
}
218204
```
219205

220-
👓 See [custom routing w/ the static buildpack](https://github.com/heroku/heroku-buildpack-static#custom-routes).
206+
### Changing the root
207+
208+
If a different web server `"root"` is specified, such as with a highly customized, ejected create-react-app project, then the new bundle location may need to be [set to enable runtime environment variables](#user-content-custom-bundle-location).
209+
210+
### Routing
211+
212+
🚥 ***Client-side routing is supported by default.** Any server request that would result in 404 Not Found returns the React app.*
213+
214+
👓 See [custom routing w/ the static buildpack](https://github.com/heroku/heroku-buildpack-static/blob/master/README.md#user-content-custom-routes).
221215

222216
### HTTPS-only
223217

@@ -226,6 +220,9 @@ Enforce secure connections by automatically redirecting insecure requests to **h
226220
```json
227221
{
228222
"root": "build/",
223+
"routes": {
224+
"/**": "index.html"
225+
},
229226
"https_only": true
230227
}
231228
```
@@ -235,16 +232,19 @@ Prevent downgrade attacks with [HTTP strict transport security](https://develope
235232
```json
236233
{
237234
"root": "build/",
235+
"routes": {
236+
"/**": "index.html"
237+
},
238238
"https_only": true,
239239
"headers": {
240240
"/**": {
241-
"Strict-Transport-Security": "max-age=7776000"
241+
"Strict-Transport-Security": "max-age=31557600"
242242
}
243243
}
244244
}
245245
```
246246

247-
* `max-age` is the number of seconds to enforce HTTPS since the last connection; the example is 90-days
247+
* `max-age` is the number of seconds to enforce HTTPS since the last connection; the example is one-year
248248

249249
### Proxy
250250

@@ -273,6 +273,9 @@ Add `"proxies"` to `static.json`:
273273
```json
274274
{
275275
"root": "build/",
276+
"routes": {
277+
"/**": "index.html"
278+
},
276279
"proxies": {
277280
"/api/": {
278281
"origin": "${API_URL}"

0 commit comments

Comments
(0)

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