Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to perform domain verification for Firebase functions

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.

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...

This fails when trying to deploy.

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...

and

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

Also fail.

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

like image 334
Nick Felker Avatar asked Apr 04 '18 22:04

Nick Felker


1 Answers

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

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.

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

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"
      }
    ]
  }
}

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

like image 168
hKaspy Avatar answered Sep 24 '22 07:09

hKaspy