Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase: How do you add a vanity URL to a cloud function?

Was briefly mentioned here, but right now I'm at the point where I've connected my GCP project to Firebase, set up a custom domain under Firebase hosting, but on the functions page of the Firebase dashboard, there doesn't seem to be a way to set the vanity URL on a cloud function.

My firebase.json (at the root of my project) looks like :

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

enter image description here

like image 926
sdfsdf Avatar asked Jul 22 '18 02:07

sdfsdf


People also ask

How do I change my Firebase hosting URL?

Scroll down in 'Manage Site' and create a new site, then deploy there. You can't change your domain, but you can change the host! You can make as many sites as you want.

Is it possible to get vanity URLs from Cloud Functions?

If you connect your Cloud project with Firebase, you can connect your HTTP-triggered Cloud Functions to Firebase Hosting to get vanity URLs. This user is first on the weekly Google Cloud leaderboard.

How to deploy a cloud function from Firebase?

Run firebase deploy --only functions to deploy your Cloud Function inside the functions directory. Your function was deployed but — you have an ugly link from Google. To rewrite your Cloud Function link go to the /firebase.json file. In the rewrites array add this object before the existing one:

What is the difference between Firebase CLI and cloud build?

The Firebase CLI creates a .zip archive of the function code, which is then uploaded to a Cloud Storage bucket (prefixed with gcf-sources) in your Firebase project. Cloud Build retrieves the function code and builds the function source.

How do you write a function in Firebase?

You write code for a new function, selecting an event provider (such as Cloud Firestore), and defining the conditions under which the function should execute. The Firebase CLI creates a .zip archive of the function code, which is then uploaded to a Cloud Storage bucket (prefixed with gcf-sources) in your Firebase project.


1 Answers

To associate a vanity domain with your Cloud Functions, you need to associate them with Firebase Hosting. See the documentation on connecting the two.

Say you have a Cloud Function https://us-central1-<your-project-id>.cloudfunctions.net/bigben.

After making this connection the function will also be available on https://<your-project-id>.firebaseapp.com/bigben.

If you also connect a custom domain with Firebase Hosting, the function will also be available on https://<your-custom-domain>.com/bigben.

like image 110
Frank van Puffelen Avatar answered Nov 11 '22 00:11

Frank van Puffelen