URL中的Firebase宿主路径参数不工作
在firebase上托管时,我需要通过使用路径参数从URL获取URL中的Firebase宿主路径参数不工作,firebase,url-rewriting,firebase-hosting,Firebase,Url Rewriting,Firebase Hosting,在firebase上托管时,我需要通过使用路径参数从URL获取id来提供动态内容。例如: mydomain.com/apps/4480023 在这个场景中,我想提取4480023作为我要查找的资源的ID。我在firebase.json文件中尝试了以下更改: { "hosting": { "public": "public", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**"
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文件最终都无法正常运行
如何修改此项以启用此功能?将按顺序检查重写。这意味着您的第一次重写(匹配所有请求)将始终由index.html提供服务 您所要做的就是更改重写顺序,以允许
/apps/**
在捕获所有其他内容之前有可能进行匹配
"rewrites": [
{
"source": "/apps/**",
"destination": "/apps.html"
},
{
"source": "**",
"destination": "/index.html"
}
]
我不认为这会导致这个问题。谢谢:)你能分享一下firebase排序后如何提取参数的代码吗。json@Hanzala你是说查询参数吗?比如:
website.com?user=2