How to navigate to Confluence Space page (or how to get forgeEnvId )

We would like to route users from some custom ui elements and macros to space page.

Theres router that we can use for that, but some information is missing. The space page has following path: /spaces/:spaceKey/apps/:appId/:forgeEnvId/:route
appId is known, but where do we get forgeEnvId ?
Have tried to look for the data from different contexts but have not succeeded.

tnx!
Margus

1 Like

Hello Margus,

I can see the env ID in the forge deploy --verbose output. It looks to me that it is a part of a key of your resource(s).

I still does not know whether it is static/fixed, or dynamic (e.g. after deployment), or whether it is safe to extract this ID from the deploy logs…

Same doubts here as well. We have no idea when the id changes. We could also find it from atlas doc format in some cases (https://host.atlassian.net/wiki/rest/api/content/64018651642294?expand=body.atlas_doc_format) but again if you dont use some macros from this app on a page then extracting it is worthless. Lets hope some Atlassian adds the id to some contexts.

Hi there, sorry for the late reply. The environment ID is a unique ID that corresponds to a Forge app environment — (development, staging, production) and is stable for that environment.

1 Like

Tnx for the reply @nhur
So its ok to “hard-code” the string to our navigation paths in production while we cannot get it via forge?

1 Like

Hi! @nhur can you confirm that we could hardcode the paths?

tnx,
Margus

Hey @margus.nael, sorry about the late reply! You can hardcode paths for your own app since it will be stable. I’ve forwarded some feedback to see if we can replace this key with something that’s a bit easier to get.

1 Like

A more flexible workaround recommended elsewhere already is to use Forge environment variables so that you only need to set the variable once per environment and can easily update it at any time w/o code changes. For example, we build and deploy our apps via a bot user for CI/CD, and every team member registers the app anew for isolated development.

@sopel Are the env variables persistent enough? In staging and dev yeah that would be our approach also, but how does env variables work at all in forge “sandboxes”. Since we really do not know how the forge environments are built and how the environment around our app can actually change I still would go with some hardcoded strings.
Thus are you sure that the environments are built so that your env variables are consistently carried on to new one. Sry for my scepticism but its just life that has given some painful lessons and not everything is still available if we’re talking about forge and the technical solution+docs.

1 Like

There is another way to get the envIds.

  • Open the Developer Console ( Developer console ) in your browser
  • Activate/Open the browsers Network tab
  • Select the App within your My apps list
  • Go into the Network tab and search for graphql with the Request Payload {operationName: “forgeAppDetailsResult” …}
  • You will find the envIds of PRODUCTION, STAGING and DEVELOPMENT within the Response of the graphql request