For anyone still looking for a solution to this: Here is how I currently check whether a user agent is from facebook:
const agent = request.headers["user-agent"]if (agent.toLowerCase().includes("facebook")) response.send(<payload>)else response.redirect(<path-to-index.html>)
The request
/ response
variables are the ones, received through functions.https.onRequest((request, response) => { ... })
. For more information, check the Firebase Docs and Express Docs.