Access function complete url from the function itlself


I was wondering if it possible to access the complete URL of a function from the function itself?
The event object contains the path and query parameters, but not the hostname/domain piece

For example, one of my functions would like to determine if it is running under or

Alternatively, there is maybe a way to reference “relative” resources within the function code?
Example: generates a link to
and generates a link to


Hi @tvanier, it’s possible to get the site url from the context object, specifically context.clientContext.custom.netlify. The following snippet shows how you would decode the base64-encoded data using javascript:

function extractNetlifySiteFromContext(context) {
  data = context.clientContext.custom.netlify
  decoded = JSON.parse(Buffer.from(data, "base64").toString("utf-8"))
  return decoded

Let me know if that works for you.