在深度刷新Firebase之后反应生产路由器404 [英] React production router 404 after deep refresh firebase
本文介绍了在深度刷新Firebase之后反应生产路由器404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的index.js中有这条路线
i have this routes in my index.js
<Router history={customHistory}>
<div className="row">
<Switch>
<Route exact path="/login" component={Login}/>
<Route path="/home" component={Home}/>
<Route path="/politicas" component={Policies}/>
<Redirect exact from="/" to="/login"/>
<Route exact path="*" status={404} component={NotFound}/>
</Switch>
</div>
</Router>
在本地环境中总能正常工作,但是我有一个Firebase应用程序来部署我使用的Firebase项目:
In local enviroment always works but i have one firebase application, to deploy my firebase project i use:
npm运行构建
npm run build
和
firebase部署
firebase deploy
但是在firebase应用中,深度刷新返回404后,唯一可行的路由是"/",我该怎么做才能使路由始终与任何路径兼容?
But in firebase app after deep refresh returns 404, the only route that works is "/", What do I have to do to keep the routes always working with any path?
推荐答案
我回答自己,有必要将以下内容添加到文件firebase.json
I answer myself, it is necessary to add the following to the file firebase.json
"hosting": {
// Add the "rewrites" section within "hosting"
"rewrites": [ {
"source": "**",
"destination": "/index.html"
} ]
}
这篇关于在深度刷新Firebase之后反应生产路由器404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文