【问题标题】:firebase hosting get ERR_TOO_MANY_REDIRECTS for use dynamic redirectfirebase 托管获取 ERR_TOO_MANY_REDIRECTS 以使用动态重定向
【发布时间】:2018-11-01 07:02:01
【问题描述】:

我正在使用 Firebase 托管 SPA (create-react-app) 我想在 url ex 中获取参数动态:https://www.exmaple.com/home/:id

我关注文档:https://firebase.google.com/docs/hosting/full-config#section-glob

所以我在 firebase.json 中有代码

{
"hosting": {
"public": "build",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"redirects": [
  {
    "source": "/home/:id",
    "type" : 301,
    "destination": "/home/:id"
  }
]
}
}

结果是我得到 ERR_TOO_MANY_REDIRECT,当我查看网络中的调试器工具时,它重定向到相同的路径。

我试过了,输入 301、302 甚至重写属性然后得到 404 响应。

【问题讨论】:

    标签: firebase firebase-realtime-database routing google-cloud-functions firebase-hosting


    【解决方案1】:

    您的来源是"/home/:id",因此匹配该 URL 模式的请求将被重定向。然后你告诉它重定向到"/home/:id"。重定向发生后,请求再次匹配为需要重定向的请求,因此它将被重定向,直到浏览器停止它。

    你必须从一个地方"/home/:id"重定向到另一个地方"/other/:id"

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-09
      • 2015-12-07
      • 1970-01-01
      • 2016-03-16
      • 2021-09-12
      • 2019-03-26
      • 2021-06-30
      • 2019-09-10
      相关资源
      最近更新 更多