3

I have a service that shares html to multiple client web sites. I need to know The URL of where the request is coming from.

The client will add a custom script to their website and the script will load Firebase SDK and call one of my callable firebase functions.

exports.testFunction = functions.https.onCall(async (data, context) => {
    //How do you access the requesting URL?
    console.log(context.rawRequest.originalUrl) "/"
    console.log(context.rawRequest.url) "/"
})

Thank you,

1
  • 1
    You'll have to pass in the URL into the cloud function by the page making the request. use window.location.href to get the page URL and load it into data Commented Apr 29, 2020 at 21:58

1 Answer 1

4

HTTP requests to callable functions don't really come "from" a URL. They come from anywhere on the internet. It could be a web site, Android or iOS app, or someone who simply knows the protocol to call the function.

If you're building a web app and you want to pass along the URL of the page making the request, you'll have to add that data into the object that the client passes to the function, which shows up in data.

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.