“源"到底是什么?在Firebase重写的上下文中? [英] What exactly is "source" in the context of Firebase rewrites?

查看:107
本文介绍了“源"到底是什么?在Firebase重写的上下文中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了Firebase文档,并多次观看了其他教程,但没有一个教程明确说明了源代码. 因此,按照莱曼的说法,在下面的代码上下文中,确切的来源是什么?

I've read the Firebase documents and watched other tutorials multiple times and none of them explicitly explained what source was. so in Layman's terms, what exactly is source in the context of the code below?

"hosting": {
  // ...

  // Add the "rewrites" attribute within "hosting"
  "rewrites": [ {
    "source": "/bigben",
    "function": "bigben"
  } ]
}

推荐答案

通过声明重写,如下所示

"rewrites": [ {
    "source": "/bigben",
    "function": "bigben"
  } ]

您实际上是按照文档中的说明直接将请求托管到您的函数" a>.

you actually "direct hosting requests to your function" as explained in the documentation.

如果您查看有关如何配置重写的文档,您将看到

If you look at the documentation about how to configuring the rewrites, you will see that for

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

rewrites属性包含一个重写规则数组,其中每个规则 规则必须包括:

The rewrites attribute contains an array of rewrite rules, where each rule must include:

  • 一个来源,它指定了一种球形模式

  • A source specifying a glob pattern

目标 ,这是必须存在的本地文件

A destination, which is a local file that must exist

这样做

  "rewrites": [ {
    ...
    "function": "bigben"
  } ] 

代替

  "rewrites": [ {
    ...
    "destination": "...."
  } ]

您将重定向到bigben函数,如这里.

因此,按照"Layman的说法",平台会将来自一个或多个来源的传入请求重定向到一个或多个目的地,并且在您的情况下,还会将目的地重定向到是一个云功能.

So, "in Layman's terms", the platform redirects incoming requests coming from one or more sources to one or more destinations, and, in your case, the destination is a Cloud Function.

这篇关于“源"到底是什么?在Firebase重写的上下文中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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