Firebase 不断将 example.com/username 重定向到 example.com/#/

Firebase keeps redirecting example.com/username to example.com/#/

我正在尝试从当前 URL 示例中提取用户名。com/username 但 firebase 一直将其定向到 example.com/#/ 由于用户名动态变化。

网站是基于flutter构建的

firebase.json 文件:

{
  "firestore": {
    "rules": "firestore.rules",
    "indexes": "firestore.indexes.json"
  },
  "functions": {
    "predeploy": [
      "npm --prefix \"$RESOURCE_DIR\" run lint"
    ],
    "source": "functions"
  },
  "hosting": {
    "public": "build/web",
    "ignore": [
      "firebase.json",
      "**/.*",
      "**/node_modules/**"
    ],
    "rewrites": [
      {
        "source": "/**",
        "dynamicLinks": true,
        "destination": "/index.html"
      }
    ]
  },
  "storage": {
    "rules": "storage.rules"
  }
}

视觉效果:

如果我们查看 firebase.json 中的 rewrites 节点:

"rewrites": [
  {
    "source": "/**",
    "dynamicLinks": true,
    "destination": "/index.html"
  }
]

这会告诉 Firebase 托管将任何传入路径 ("source": "/**") 重写到同一个 index.html 文件 ("destination": "/index.html")。

如果您不希望它执行此重写,您应该将其从 firebase.json 配置文件中删除。