如何执行Firebase功能的域验证 [英] How to perform domain verification for Firebase functions

查看:83
本文介绍了如何执行Firebase功能的域验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Google的网站站长工具为我的网站"添加域验证,该网站完全由Cloud Functions for Firebase组成:

I'd like to use Google's Webmaster Tools to add domain verification for my "site", which is entirely made up of Cloud Functions for Firebase:

https://us-central1-<project-id>.cloudfunctions.net/

但是我无法弄清楚如何以一种可以成功运行的方式进行操作.

However I cannot figure out how to do this in a way that would work successfully.

推荐的方法是下载并提供带有验证码的HTML文件.但是,我似乎无法用点创建函数.

The recommended way is to download and serve an HTML file with a verification key. However, I cannot seem to create a function with a dot.

exports['googleKEY.html'] = functions...

尝试部署时失败.

另一种方法是在我的主页"中放置一个meta标记,但这也无法正常工作,因为我似乎无法创建索引页面.

An alternative is to put a meta tag in my "homepage", but that also does not work as I cannot seem to create an index page.

exports[''] = functions...

exports['index.html'] = functions...

也失败了.

有没有一种方法可以仅通过功能进行域验证?我很感谢指导.

Is there a way to do this domain verification just through functions? I'd appreciate guidance.

推荐答案

所以...我想我终于可以找到解决方法了.

So... I think I finally may have a solution.

没有直接的方法来验证Firebase功能域(https://*.cloudfunctions.net),但是验证Firebase托管域(https://*.firebaseapp.com)很容易(

There is no direct way to verify a Firebase Functions domain (https://*.cloudfunctions.net) BUT verifying Firebase Hosting domain (https://*.firebaseapp.com) is easy (using verification file). So let's start with that.

托管"中有一个配置选项,用于设置URL重写以提供功能. (在此处记录)

There is a config option in Hosting to setup url rewrite to serve a Function. (Documented here)

这是上面链接中的修改后的示例配置,打开URL https://<your-project-id>.firebaseapp.com/covertFnBigben以调用功能bigben.

This is a modified example config from the link above, opening url https://<your-project-id>.firebaseapp.com/covertFnBigben to invoke Function bigben.

{
  "hosting": {
    "public": "public",

    // Add the following rewrites section *within* "hosting"
    "rewrites": [
      {
        "source": "/covertFnBigben", "function": "bigben"
      }
    ]
  }
}

因此,在成功验证Firebase托管域后,您可以使用该域来调用Firebase功能.

So after successfull verification of your Firebase Hosting domain you can use that domain to call Firebase Functions.

这篇关于如何执行Firebase功能的域验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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