HTTPS Callable functions and headers

669 views
Skip to first unread message

Laurent Pellegrino

unread,
Jun 8, 2018, 4:19:41 AM6/8/18
to Firebase Google Group
Hi there,

HTTPS Callable functions are really convenient. However, I cannot find a way to access headers from the server when functions.https.onCall is executed.

My purpose is to get the user IP and detect it's browser language.

Is there a solution?

Kind Regards,

Laurent Pellegrino

Bryan Klimt

unread,
Jun 8, 2018, 4:57:58 PM6/8/18
to Firebase Google Group
Hi Laurent,

Currently, there is no way to access the raw headers inside a functions.https.onCall handler. Probably the two easiest workarounds would be either to 1) use an https.onRequest handler and parse the request yourself, or 2) put the browser language into the params passed to the function from within your client.

-Bryan

Laurent Pellegrino

unread,
Jun 9, 2018, 12:30:51 PM6/9/18
to Firebase Google Group
Hi Bryan,

Thanks for your answer. 

The second solution requires a previous request to know the IP or browser language values to pass to the function.

The first solution is obvious but the purpose was to use a callable to avoid validating auth tokens and deserializing the request body by myself.

It's a shame to have headers completely hidden from the HTTPS Callable API. Information is there, we could avoid boilerplate code and prevent useless requests but no, we can't access it :(

Kind Regards,

Laurent Pellegrino 
Reply all
Reply to author
Forward
0 new messages