Firebase:在URL重写中传递URL参数 [英] Firebase: Pass url Param in URL Rewrite

查看:85
本文介绍了Firebase:在URL重写中传递URL参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于firebase文档中的代码示例,它说要像这样启动url重写:

For the code examples in the firebase docs, it says to initiate a url rewrite like so:

        "hosting": {
          // Add the "rewrites" section within "hosting"
          "rewrites": [ {
            "source": "**",
            "destination": "/index.html"
          } ]
        }

当我要将参数传递给索引页时该怎么办?我尝试过:

What do I do when I want to pass a parameter to the index page? I tried:

        "hosting": {
          // Add the "rewrites" section within "hosting"
          "rewrites": [ {
            "source": "/item/**",
            "destination": "/item.html?i=$1"
          } ]
        }

但是那什么也没做..

我也尝试过以下答案:

 "hosting": {
  // Add the "rewrites" section within "hosting"
  "rewrites": [ {
    "source": "/item/:item",
    "destination": "/item.html?i=:item"
  } ]
}

但这只会返回404页面.

but that just returns a 404 page.

推荐答案

我刚收到以下来自Firebase支持的电子邮件:

I have just received an email from Firebase support with the follwing:

从Firebase支持更新:

Update From Firebase support:

单独使用Firebase Hosting无法实现您的用例.您还需要利用云功能. Firebase最近发布了本机Firebase Hosting + Functions集成,该集成使执行服务器端处理成为可能,因此您可以将URL重定向到可以编写代码以剖析路径并生成所需响应的函数.您可以查看我们的文档以了解更多详细信息.

Your use case is not possible with Firebase Hosting alone. You will need to make use of Cloud Functions as well to do so. Firebase has just recently released a native Firebase Hosting + Functions integration which makes it possible to perform server-side processing so you can redirect URLs to a function where you can write code to dissect the path and generate whatever response you want. You may check our documentations out to know more about it in detail.

https://firebase.google.com/docs/hosting/functions

我已通过电子邮件将其发送回去,以查看是否将来会添加此内容,因为运行到一页的进程似乎有点过头了.

I have emailed them back to see if this is something that will be added in the future as it seems a little overkill to run to processes for one page.

由于不支持此功能,因此我已向您提出功能请求.但是,我目前无法分享任何详细信息或时间表.不过,我们会一直考虑您的反馈意见.

Since this is not supported, I have filed a feature request for you. However, I am not able to share any details or timelines for now. We'll keep your feedback in consideration moving forward though.

同时,您可以关注我们的发行说明.

In the meantime, you may keep an eye out on our release notes.

祝你有美好的一天.

https://firebase.google.com/support/releases

这篇关于Firebase:在URL重写中传递URL参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆