Last updated Jun 25, 2024

This section describes a Forge preview feature. Preview features are deemed stable; however, they remain under active development and may be subject to shorter deprecation windows. Preview features are suitable for early adopters in production environments.

We release preview features so partners and developers can study, test, and integrate them prior to General Availability (GA). For more information, see Forge release phases: EAP, Preview, and GA.

Calling a remote backend from a Forge function

You can call your remote backend from your Forge functions. The diagram below illustrates the data flow.

Forge Remote diagram describing the flow of data and auth between Forge and remote application

Getting started

To call your remote backend from a function you need to define a remote in your manifest.yml.

Example manifest

Here's an example of how to set up your manifest:

1
2
modules:
  trigger:
    - key: update-issue
      function: main
      events:
        - avi:jira:updated:issue
  function:
    - key: main
      handler: index.run
remotes:
  - key: remote-app-node
    baseUrl: https://forge-remote-refapp-nodejs.services.atlassian.com
    operations:
      - compute
    auth:
      appSystemToken:
        enabled: true

Calling your remote from a function

To call your remote from a function, you can use the invokeRemote method from the @forge/api package. This function allows you to make HTTP requests to your remote backend.

For example, a GET request to a remote endpoint could look like this:

1
2
import { invokeRemote } from "@forge/api";

const res = await invokeRemote('remote-app-node', {
  path: `/tasks/?team=Forge`,
  method: 'GET'
});

if (!res.ok) {
  throw new Error(`invokeRemote failed: ${res.status}`);
}

const json = await res.json();
console.log(`Tasks: ${JSON.stringify(json)}`);

Verifying requests

You will need to verify the requests received by your remote came from Atlassian and are intended for your app. For more information on how to do this, see Verifying remote requests.

Next steps

Now that you’ve verified the requests and have received your access tokens, you can:

Rate this page: