UPDATE: create-react-app-buildpack now has routing built in by default!
Unless you want further customization, the buildpack will automatically use the configuration below (meaning you don’t need to do anything)!
The (outdated) post is maintained below, for posterity.
Just add a static.json
file!
$ cd MY-APP
$ echo '{
"root": "build/",
"routes": {
"/**": "index.html"
}
}' > static.json
This tells the create-react-app buildpack to send ALL requests to index.html
, otherwise you’ll get 404’s when trying to hit your routes (i.e. /signup
).
How to Deploy Your React App to Heroku
Create-React-App Buildpack README (section about React Router)