我有两个功能,部署在一个firebase项目中。我想实现的是根据URL路径启动不同的代码:
这是我的示例配置
{
"hosting": {
"public": "functions/dist",
"rewrites":[
{
"source": "/path1/**",
"destination": "function1"
},
{
"source": "/path2/**",
"destination": "function1"
},
{
"source": "**",
"function": "function2"
}
]
}
}
不幸的是,所有内容都路由到function2。我应该如何更改我的配置?
答案 0 :(得分:-1)
尝试下面的代码。
rewrites =函数, 重新定向=目的地
{
"hosting": {
"public": "functions/dist",
"redirects": [ {
"source": "/path1/**",
"destination": "function1"
}, {
"source": "/path2/**",
"destination": "function1"
} ],
"rewrites":[
{
"source": "**",
"function": "function2"
}
]
}
}
引用:https://firebase.google.com/docs/hosting/url-redirects-rewrites