【发布时间】:2018-10-20 06:32:22
【问题描述】:
在 Firebase 上托管时,我需要通过使用路径参数从 URL 中获取 id 来提供动态内容。例如:
mydomain.com/apps/4480023
在这种情况下,我想提取 4480023 作为我要查找的资源的 ID。我在 firebase.json 文件中尝试了以下更改:
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
},
{
"source": "/apps/**",
"destination": "/apps.html"
}
],
"cleanUrls": true
}
}
在这种情况下,当用户浏览到该资源时,我可以使用 javascript 函数从 URL 中检索 ID。我的问题是,这种重写不起作用,它会将用户引导到 index.html 页面,并且所有 CSS/JS 文件最终都无法正常运行。
如何修改它以启用此功能?
【问题讨论】:
-
可以分享一下firebase.json排序后如何提取param的代码
-
@Hanzala 你的意思是查询参数吗?喜欢:
website.com?user=2
标签: firebase url-rewriting firebase-hosting