Abe*_*vez 4 firebase reactjs firebase-hosting
我的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>
Run Code Online (Sandbox Code Playgroud)
在本地环境中总能正常工作,但是我有一个firebase应用程序,要部署我使用的firebase项目,我可以使用:
npm运行构建
和
火力基地部署
但是在firebase应用中,深度刷新返回404后,唯一可行的路由是“ /”,我该怎么做才能使路由始终与任何路径兼容?
Abe*_*vez 10
我回答自己,有必要将以下内容添加到文件firebase.json中
"hosting": {
// Add the "rewrites" section within "hosting"
"rewrites": [ {
"source": "**",
"destination": "/index.html"
} ]
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1324 次 |
最近记录: |