Qui*_*Kim 4 firebase reactjs react-router
我有一条路线https://playlists-22855.firebaseapp.com/client/create,当尝试通过单击“主题”链接访问时,我可以正常访问。但是当我尝试通过地址栏直接访问该路由时,出现 404 错误。我想知道如何更正我的代码,可以在 codeandbox 上找到。另一个有趣的事情是,代码在 codeandbox 上按预期运行得很好,但它有一个 create react app 应用程序,而我的不是。谢谢你。
小智 9
我也有这个问题 - 我通过将我的应用程序配置为单页应用程序来修复它。当您最初这样做时,firebase init您可以选择此作为选项。现在,您可以通过手动更改您的firebase.json文件。
您想将此添加到您的 firebase.json
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
Run Code Online (Sandbox Code Playgroud)
所以你firebase.json会看起来像这样
{
"hosting": {
"target": "your-app-name",
"public": "your-build-directory",
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1063 次 |
| 最近记录: |