How to get the URL of a Forge app in Jira?

I have a forge app that’s being loaded as jira:projectPage. Its name and link show up in the nav bar in Jira. How can I programatically produce the URL to take a user to the page with my app selected? E.g

https://.atlassian.net/jira/software/projects/TEST/apps/<id 1>/<id 2>

I’m redirecting the user to a new page to do something - and would like to redirect them back to Jira with my app selected, to pick up where they left off.

Hi @aliakhtar

If your app is a Custom UI app, you might be able to leverage the createHistory method to allow to redirect to where your user was.

See the documentation here: https://developer.atlassian.com/platform/forge/custom-ui-bridge/view/#createhistory

As noted, the jira:projectPage is one of the supported modules.

Hope this helps.

Thanks @XavierCaron but I actually need to open a popup window via resolver.open (a workaround to get microphone access) - so users will be on a site outside of Jira where I’ll get their voice command via microphone. Then I need to redirect them back to Jira.

So I can’t use the createHistory bridge as they will be on an external site outside of Jira. I need an independent way to generate the URL that’ll take them back to Jira with my app selected. How can I do that?

I’m also interested in this. My use case is that I’m using Custom UI for a Jira project page, and I want to generate a URL which the user can share as a link, but I couldn’t see anything in the docs about how to do this.

The createHistory bridge only provides relative paths, and the window.location object appears to maintain a reference to a CDN (e.g. f79f0bb1-0f9b-4ce1-82b6-6af0ecd669bb.cdn.prod.atlassian-dev.net) so I need to figure out the actual Jira app root (i.e. the url of the project page).

I did notice how I can potentially piece together the URL, but it’s based on a few assumptions:

  1. Suppose my project page is at https://example.atlassian.net/jira/software/projects/MYPROJ/apps/app-id/other-id.
  2. Suppose also that I navigate to /my-page?foo=bar using react-router in my custom UI. (The full URL would then be https://example.atlassian.net/jira/software/projects/MYPROJ/apps/app-id/other-id/my-page?foo=bar.)
  3. Then the result of view.getContext() (from the @forge/bridge package) looks like the below.
{
  extension: {
    project: {key: "MYPROJ", type: "software", id: "10000"}
  },
  type: "jira:projectPage",
  localId: "ari:cloud:ecosystem::extension/app-id/other-id/static/my-app"
}
  1. Therefore, I can get the project key from context.extension.project.key, and I can parse context.localId to get the application id and the “other id”. (Anyone know what this second ID is called or is for btw?)
  2. I can get the baseUrl (https://example.jira.com) from the /rest/api/3/serverInfo URL.
  3. This allows me to piece together the full URL of the app, assuming a template of {baseUrl}/jira/software/projects/{projectKey}/{appId}/{otherId}.
  4. I can then simply append the relative URL of my custom UI page (/my-page?foo=bar) to this URL for the app in order to get the link to share.

So this looks like it should work. However, I have a couple of questions:

  1. Is this approach guaranteed to work in future, or am I making assumptions about the format of the localId and the URL scheme?
  2. Is there a better way to get the app URL? (Certainly, this seems a lot of work.)
1 Like