Get url of another http cloud function for firebase in code

I want to get the url of the http cloud function for firebase in another cloud function for firebase instead of hardcoding. Is it possible?

It doesn't work, but is there a way to do something like this?

exports.helloWorld = functions.https.onRequest((req, res) => {
    res.send("Hello!");
});

exports.anotherFunction = functions.https.onRequest((req, res) => {
    const url = exports.helloWorld.url;
    res.send(url); // https://us-central1-project-id.cloudfunctions.net/helloWorld
});     

      

+3


source to share


1 answer


Since these two functions are in the same project, they will always have the same hostname in the URL. I would just make the client assume this is true and make anotherFunction just return "helloWorld". The client can then compose the full URL of the helloWorld function by adding that path to the hostname they are already using to access another function.



+1


source







All Articles