我只是使用Firebase CLI在一个静态托管项目中。当您启用“配置为单页应用程序”选项时,会发生什么?我正在寻找一个确切的描述哪些文件被修改,以及这会对Firebase后端产生什么样的影响。

发布于 2016-06-07 16:06:49
该选项只需在firebase.json文件中设置一个标志,将所有URL重定向到/index.html。
"rewrites": [ {
  "source": "**",
  "destination": "/index.html"
} ]有关更多信息,请参见Firebase托管文档,其中还包含了这个更完整的示例:
“宿主”:{ // ./在“宿主”“重写”中添加“重写”属性:{/ index.html,用于处理对不存在“源”:"**“、”目的地“:"/index.html”}的文件或目录的请求。{ // index.html用于请求"/foo“和"/foo/**”//使用"/foo/**“只匹配"/foo/xyz”之类的路径,但不匹配"/foo“源:"/foo{,/**}",”目的“:"/index.html”},{/排除指定路径重写“/foo”:“/@(Js)/**”,“目的地”:"/index.html“}
发布于 2017-01-16 19:49:25
完整的例子:
{
  "hosting": {
    "public": ".",
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ]
  }
}发布于 2019-11-22 16:21:14
如果您将其设置为“是”,那么所有像www.example.com/some-invalid-url这样的无效URL都将被重定向到站点的index.html,这是一件好事。您还可以将其设置为自定义404.html。
firebase.json
{
  "hosting": {
    "public": "pubic",
    "ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
    "rewrites": [
      {
        "source": "**",
        "destination": "/index.html"
      }
    ],
    "cleanUrls": true
  }
}奖励:将cleanUrls设置为true以从部署的网站urls中删除.html扩展,否则所有没有.html的urls都将重定向到index.html。
https://stackoverflow.com/questions/37667626
复制相似问题