【发布时间】:2021-02-13 21:51:26
【问题描述】:
首页刷新成功。但是对于任何其他路线,当我刷新页面时会变为空白。
例子:
.../view/5f9ad1c453db51de5e52f94d
.../browse/movies/
这里是上面的设置:
1- Nginx 配置
.
.
.
root /var/www/html/build;
location / {
try_files $uri $uri/ /index.html;
}
index index.html;
.
.
.
2- 反应
<Router history={history}>
<Nav />
<div className="container mx-auto padding-m">
<Switch>
<Route exact={true} path="/" component={Home} />
<Route path="/browse/movies/*" component={Browse} />
<Route path="/view/:id" component={View} />
<Route path="/category/:id" component={Category} />
</Switch>
</div>
<Footer />
3- 版本
----
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-js-pagination": "^3.0.3",
"react-router-dom": "latest",
"react-scripts": "3.4.3",
----
我已经尝试将"homepage": "./" 添加到package.json
我没有尝试弹出和更改 webpack 设置,
有什么建议吗?
我已经检查了以下答案,但它对我不起作用: blank page when refreshing in react router
【问题讨论】:
标签: reactjs nginx react-router