在特定路径上调用云函数

问题描述 投票:0回答:1

我在每个请求上都调用一个函数。我可以从重写中排除/ test目录吗?

{
   "hosting":{
      "public":"build",
      "ignore":[
         "firebase.json",
         "**/.*",
         "**/node_modules/**"
      ],
      "rewrites":[
         {
            "source":"/**",
            "function":"helloWorld"
         },
         {
            "source":"**",
            "destination":"/index.html"
         }
      ]
   },
   "functions":{
      "predeploy":[
         "npm --prefix \"$RESOURCE_DIR\" run lint"
      ]
   }
}
firebase google-cloud-functions firebase-hosting
1个回答
2
投票

正如所写,由于您有两条**路线,因此规则重叠的方式没有意义。第二个(指向index.html)将永远不会匹配。您可以使用否定来完成您要提出的建议:

{
  "rewrites": [
    {"source": "!{/test/**}", "function": "helloWorld"}
  ]
}
© www.soinside.com 2019 - 2024. All rights reserved.