3

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
});     

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.