Firebase 在子文件夹中的单页 VueJS 应用程序中重写

Firebase rewrites in single page VueJS app in subfolder

背景

我有一个结构如下的网站:

root
  — /public
    — index.html <— landing page
    — 404.html
    — /library 
      — index.html <— single page VueJS app

在此处找到单页应用程序:https://uxtools-3ac6e.firebaseapp.com/library/

这是我的 firebase.json:

{
  "database": {
    "rules": "database.rules.json"
  },
  "hosting": {
    "public": "public",
    "rewrites": [
      {
        "source": "/library/*",
        "destination": "/library/index.html"
      }
    ]
  }
}

问题

当应用程序开始路由到子路径时,如 https://uxtools-3ac6e.firebaseapp.com/library/lists/order-group-best-sources-learn-ux,刷新将重定向到 404 而不是 library/index。html。

您需要使用双星球来匹配:

"source": "/library/**"

单星只会匹配一个斜杠,所以它会匹配 /library/lists 但不会匹配 /library/lists/foo