【发布时间】:2022-01-05 22:19:32
【问题描述】:
我有一个关于使用路由的 react 应用程序重写 firebase 托管的问题 目前我在 firebase.json 文件中的重写如下所示:
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}]
它适用于直接请求,例如:
sampleDomain.com/about
react 应用显示正确/关于网站
但是当我尝试直接加载例如 mydomain.com/user/userId/post
它给了我空白页,在本地主机上它可以工作
我已经尝试添加到重写另一个位置,例如:
{
"source": "/user/**/**",
"destination": "/index.html"
}
当我在浏览器 mydomain.com/user/userId/post 中打开时 它给出了空白页。
也许有人有类似的情况
【问题讨论】:
-
"/user/**"将匹配用户下的任何文件或文件夹,所以我猜它匹配但您的页面在呈现时出现错误。
标签: reactjs firebase router firebase-hosting