Firebase:如何将虚荣网址添加到云功能?

时间:2018-07-22 02:59:45

标签: javascript firebase google-cloud-platform google-cloud-functions

曾简要提到here,但现在我已经将GCP项目连接到Firebase,在Firebase托管下设置自定义域,但在Firebase仪表板的功能页面上,似乎没有办法在云端功能上设置虚荣网址。

我的firebase.json(位于项目的根目录)看起来像:

{
    "hosting": {
        "public": "public",
        "rewrites": [
            { "source": "/helloWorld", "function": "helloWorld" },
            { "source": "/progress", "function": "progress" }
        ]
    }
}

enter image description here

1 个答案:

答案 0 :(得分:5)

要将虚荣域与您的Cloud Functions相关联,您需要将其与Firebase Hosting关联。参见documentation on connecting the two

假设您有一个Cloud Function def createEmptyList(length,fill=None): ''' return a (empty) list of a given length Example: print createEmptyList(3,-1) >> [-1, -1, -1] print createEmptyList(4) >> [None, None, None, None] ''' return [fill] * length

建立连接后,该功能也将在class Parent { static sayHello(){ ChildN.sayHi() } } class ChildOne extends Parent { static sayHi(){ console.log('hi from ChildOne') } } class ChildTwo extends Parent { static sayHi(){ console.log('hi from ChildTwo') } } ChildOne.sayHello() ChildTwo.sayHello() 上可用。

如果您还connect a custom domain使用Firebase Hosting,则该功能也将在https://us-central1-<your-project-id>.cloudfunctions.net/bigben上可用。