Get environment name from the environmentId in the backend

I followed the steps here to create a backend function.

Now I want to get the environment name of the environment my forge app is running in, but the context of the request only contains the environmentId. Is there an API call to get the environment name or an other way to get this information in the backend of my forge app?

Thanks for the answers :slight_smile:

If you’re using the new, NodeJS runtime you can use the appContext API to get the environementId and environementType (e.g. DEVELOPMENT, STAGING, PRODUCTION)


Thank you Adam for the answer. Yes, I’m using the new NodeJs runtime. Is there a way to explicitly get the environment name. My use case is something like this:

  • I create multiple DEVELOPMENT environments with forge environments create test-name-1 and forge environments create test-name-2 and deploy the app to both environments
  • now I want to figure out in my forge app what is the environment name the app is deployed to.
  • I would need to have some kind of mapping from the environmentId to the name “create test-name-1” or “create test-name-2”

I have not found an API call to do this. In my app implemented a workaround so that this is not needed if not possible, but I would prefer to be able to get the environement name

1 Like