2
votes

I have static content on firebase-hosting - where i have routing eg. ~/xxx - is possible to invoke firebase-function when someone enter this path ?

2

2 Answers

2
votes

Yes. This is a recently announced feature at Google's 2017 IO conference. You can create a rewrite alias in your firebase.json file which points to a cloud function via your domain name. This is the section of the documentation which clearly describes how it is done.

0
votes

Calling a cloud function directly from a hosted web application or mobile application is now possible from the below firebase version.

  • Firebase SDK for iOS 7.4.0 and above
  • Firebase SDK for Android 19.2.0 and above
  • Firebase JavaScript SDK 8.2.3 and above

The cloud function must be deployed in firebase and call below code from the client-side.

var showMessage = firebase.functions().httpsCallable('showMessage');
showMessage({ text: messageText })
  .then((result) => {
    // Read result of the Cloud Function.
    var sanitizedMessage = result.data.text;
  });

For more details, Click here (https://firebase.google.com/docs/functions/callable#web_1)