На производстве статический / путь относится к дочернему маршруту и не найден, поэтому фрагменты. js не найдены
https://example.com/childroute/static/js/0.94731513.chunk.js
, но это должно быть:
https://example.com/static/js/0.94731513.chunk.js
nginx conf:
location / {
index index.html;
try_files $uri $uri.html /index.html
}
пакет. json:
"homepage": ".",
webpack.config.prod. js:
const shouldUseRelativeAssetPaths = publicPath === "./"
Реактивный маршрутизатор:
import { Router } from "react-router-dom"
<Router history={ history } basename="/">
Маршруты приложения:
<Switch>
<Route exact path={ PATHS.root } component={ Accueil } />
<Route exact path={ PATHS.projets } component={ Projets } />
<Route path={ `${PATHS.projets}/:id` } component={ ProjetDetail } />
</Switch>
манифест. json:
"start_url": ".",