Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
URL中的Firebase宿主路径参数不工作_Firebase_Url Rewriting_Firebase Hosting - Fatal编程技术网

URL中的Firebase宿主路径参数不工作

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/**"

在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文件最终都无法正常运行


如何修改此项以启用此功能?

将按顺序检查重写。这意味着您的第一次重写(匹配所有请求)将始终由index.html提供服务

您所要做的就是更改重写顺序,以允许
/apps/**
在捕获所有其他内容之前有可能进行匹配

"rewrites": [
  {
    "source": "/apps/**",
    "destination": "/apps.html"
  },
  {
    "source": "**",
    "destination": "/index.html"
  }
]

我不认为这会导致这个问题。谢谢:)你能分享一下firebase排序后如何提取参数的代码吗。json@Hanzala你是说查询参数吗?比如:
website.com?user=2