Getting baseUrl in Forge

In our remote backend we on occasion need the Confluence site’s baseUrl to construct full page links.

Unlike Connect, the Forge installation event payload does not contain a baseUrl field, so we have to fetch it via alternative means. We’ve found two strategies:

  • Using siteUrl in the context of the decoded FIT, added to incoming requests by ACE’s authenticateForge
  • Using the /systemInfo endpoint

In the first siteUrl case, that field is only available on requests from a frontend function / UI module. It’s therefore not easy to write remote code that can be invoked either from a frontend request or from a Forge function, as siteUrl is only available in one of those cases.

In the /systemInfo case, the API documentation states that the response’s baseUrl field is nullable/optional. This again means it is not presumably guaranteed it will be always available.

I am aware that we can piggyback off of other requests made to the Confluence API (e.g get pages) and find the baseUrl under _links.base. However, it’s not always the case that we are making such requests out to Confluence when we need the baseUrl.

From this, I have a few questions:

  • Are there any other strategies to acquire a site’s baseUrl in a remote backend?
  • Under what circumstances is the baseUrl not provided in the /systemInfo response?
  • Is the documentation just wrong – is it always available from /systemInfo?

Thanks in advance.

The ways you mentioned should simply be the right path if you want to request from frontend only but have you considered storing the baseUrl in Forge storage (KVS) and reusing it or even storing it within your remote servers, instead of repeatedly making API calls to retrieve the siteUrl? Since you can determine the origin of the request at least once, you could persist that value and fetch it from storage whenever needed.

Regarding your last question, I wouldn’t say the Forge documentation is incorrect, but it can feel incomplete in places. In many cases, it doesn’t fully reflect real-world behavior or provide enough clarity on how things actually work in practice.