Greg Finzer
Greg Finzer

Reputation: 7054

NodeJS How to determine if running in Google Cloud Function?

How do I tell if my process is running in a Google Cloud Function?

Upvotes: 2

Views: 964

Answers (1)

guillaume blaquiere
guillaume blaquiere

Reputation: 75715

I have 2 checks in mind:

  • Firstly, if the Cloud Function env variables are set (your other question)
  • Secondly, you can check if the metadata server answer by performing a get request to it. Don't forget the header (Metadata-flavor: google). If you get a Http status code 404, you aren't on Cloud Function.

Upvotes: 2

Related Questions