why do we add this in static.json file at root =>
{
"root": "dist/",
"routes": {
"/**": "index.html"
}
}
static.json file is used with heroku-buildpack-static during deployment with heroku for handling static sites and single page web apps.
A number of options can be configured in static.json. Amongst them
Root allows you to specify a different asset root for the directory of your application. By default it is public_html/
Custom Routes
You can define custom routes that combine to a single file. This allows you to preserve routing for a single page web application. The following operators are supported:
* supports a single path segment in the URL. In the configuration below, /baz.html would match but /bar/baz.html would not.
** supports any length in the URL. In the configuration below, both /route/foo would work and /route/foo/bar/baz.
{
"routes": {
"/*.html": "index.html",
"/route/**": "bar/baz.html"
}
}
When serving a single page app, it's useful to support wildcard URLs that serves the index.html file, while also continuing to serve JS and CSS files correctly. Route ordering allows you to do both:
{
"routes": {
"/**": "index.html"
}
}
With the above configuration, your server will return the index.html for all paths and any routing is done on client side with react-router