结合 React 路由器和 Firebase 函数 api



我想知道是否有办法同时使用react-router-dom和Firebase函数。例如,React 部分有一些链接,如 mywebsite.com/pageone、mywebsite.com/pagetwo mywebsite.com/pagethree。我想添加一个来自 firebase 函数的 mywebsite.com/api 链接。我查找了Firebase文档,但它只显示执行其中一项。这可能吗?这是火碱.json

{
"hosting": {
"public": "build",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
},
{
"source": "/app/api",
"function": "app"
}
]
}
}

尝试更改重写的顺序,使通配符位于末尾。这为我解决了这个问题。

从:

"rewrites": [
{
"source": "**",
"destination": "/index.html"
},
{
"source": "/app/api",
"function": "app"
}
]

自:

"rewrites": [
{
"source": "/app/api",
"function": "app"
},
{
"source": "**",
"destination": "/index.html"
}
]

最新更新