Search code examples
firebasednsgoogle-cloud-functions

Use custom domain for firebase function http calls


Is there a way to use a custom domain for firebase cloud functions http hooks.

The default url for cloud functions looks something like this:

https://us-central1-my-awesome-app.cloudfunctions.net/ios-oauth/

And

I would like to make it look like this:

https://myawesomeapp.com/ios-oauth/

I looked around if there was some other people looking for the same solution and sure enough I found this:

https://stackoverflow.com/questions/43482224/firebase-cloud-functions-custom-domain


Solution

  • I have contacted firebase support to get some answers about this. And I was forwarded to this part in the documentation.

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

    You can use your own domain with the firebase-cloud-functions. The way to do it is by using the firebase-hosting.

    1. Connect custom domain to firebase hosting

    2. Add custom function routing to firebase.json

       {
         "hosting": {
           "public": "public",
      
           // Add the following rewrites section *within* "hosting"
           "rewrites": [{
             "source": "/bigben", "function": "bigben"
           }]
      
         }
       }
      
    3. Deploy to firebase