Reputation: 8161
I want to get the url of a http cloud function for firebase in another cloud function for firebase instead of hardcoding it. Is it possible?
This doesn't work, but is there any way of doing something similar?
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
});
Upvotes: 3
Views: 753
Reputation: 317828
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 that fact to be true, and make anotherFunction simply return "helloWorld". The client can then compose the full URL to the helloWorld function by appending that path to the hostname they are already using to access anotherFunction.
Upvotes: 1