user1184205
user1184205

Reputation: 863

Get the requesting URL in Callable Firebase Functions

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,

Upvotes: 3

Views: 857

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317968

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.

Upvotes: 4

Related Questions