【问题标题】:FIrebase hosting rewrites configuration for complex requests/linksFIrebase 托管重写复杂请求/链接的配置
【发布时间】: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


【解决方案1】:

添加

<base href="/" />

里面

 <head>

解决了问题

【讨论】:

    猜你喜欢
    • 2020-08-19
    • 2022-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-20
    • 1970-01-01
    • 2017-09-03
    • 1970-01-01
    相关资源
    最近更新 更多