Fetch External URLs in Jira Forge App

I have a Jira Cloud Forge app that must fetch data from one of my company’s API.

This is my project structure and source code:

My manifest.yml file:

  scopes:
    - read:jira-work
  external:
    fetch:
      backend:
        - 'my-backend-service-url-dev:8080/my-api/*'
        - 'my-backend-service-url-qa:8080/my-api/*'
        - 'my-backend-service-url-prod:9080/my-api/*'

My src/frontend/index.jsx file:

import React, { useEffect, useState } from 'react';
import { invoke, requestJira } from '@forge/bridge';
import ForgeReconciler, { useProductContext } from '@forge/react';
// some imports are hidden for brevity

const App = () => {
  
  const context = useProductContext();
  const [response, setResponse] = useState(null);

  const performRequest = async () => {
    invoke('my-backend-resolver-fetch-function', {
      id: id,
      myDomainData: myDomainData,      
      user: context.accountId }).then(setResponse);
      /*sometimes this will print 'null' until I call this function "performRequest" again
      although this is not my main issue, it is also quite annoying, is there a way to "force"
      some sort of wait on my .then(setResponse)? */
     console.log(`Backend response: ${response}`);
  } 

}

My src/resolvers/index.js file:

import Resolver from '@forge/resolver';
import api, { fetch, route } from "@forge/api";

const resolver = new Resolver();

resolver.define('my-backend-resolver-fetch-function', async (req) => {
    var id = req.context.id;
    var user = req.context.user;
    const body = JSON.stringify({
        id : id,
        user : user
    });

    const url = 'http://my-backend-service-url-dev:8080/my-api/my-resource';
    const response = await fetch(url, {
        method: 'POST',
        body: JSON.stringify(body),
        headers: {'Content-Type': 'application/json'}
     });
     try {
         if (response.ok) {
             const responseJson = await response.json();
             // by the way, the `console.log()` on resolvers never actually outputs
             // to the browser console on F12 (developer tools)
             console.log(`Successful operation: ${responseJson}`);
             return responseJson;
         } else {
             console.log(`Failed operation: ${response}`);
             return response;
         }
     } catch (error) {
         return error;
     }
});

export const handler = resolver.getDefinitions();

Finally, the issues:

  1. I sent the ‘my-backend-resolver-fetch-function’ to the backend resolver because calling (fetching) the API on the frontend was throwing an error
  2. Fetching the URL with ‘http://’ on the resolver throws the following error:
 Uncaught (in promise) Error: There was an error invoking the function - Only HTTP(S) protocols are supported
    at invoke (https://jira-frontend-bifrost.prod-east.frontend.public.atl-paas.net/assets/async-forge-ui-issue-view-extension.673c2a5b.js:38:55839)
    at async https://jira-frontend-bifrost.prod-east.frontend.public.atl-paas.net/assets/async-forge-ui-issue-view-extension.673c2a5b.js:38:86137
  1. Fetching the URL without the http throws the following error:
global-bridge.js:2 
 Uncaught (in promise) Error: There was an error invoking the function - request to http://my-backend-service-url-dev:8080/my-api/my-resource failed, reason: getaddrinfo ENOTFOUND my-backend-service-url-dev
    at invoke (https://jira-frontend-bifrost.prod-east.frontend.public.atl-paas.net/assets/async-forge-ui-issue-view-extension.673c2a5b.js:38:55839)
    at async https://jira-frontend-bifrost.prod-east.frontend.public.atl-paas.net/assets/async-forge-ui-issue-view-extension.673c2a5b.js:38:86137

Error: There was an error invoking the function - request to http://my-backend-service-url-dev:8080/my-api/my-resource failed, reason: getaddrinfo ENOTFOUND my-backend-service-url-dev
    at fe.error (

I also tried adding the following to my manifest.yml file:

remotes:
  - key: backend-dev
    baseUrl: "http://my-backend-service-url-dev:8080"
    operations:
      - fetch
  - key: backend-qa
    baseUrl: "http://my-backend-service-url-qa:8080"
    operations:
      - fetch
  - key: backend-prod
    baseUrl: "http://my-backend-service-url-prod:9080"

But that’ll lead to the following error upon running forge deploy:

Deploying your app to the development environment.
Press Ctrl+C to cancel.

Running forge lint...
No issues found.

× Deploying my-jira-cloud-forge-app to development...

i Packaging app files
i Uploading app
i Validating manifest

Error: Invalid Egress permissions: Invalid URL detected for EGRESS permissions object: http://my-backend-service-url-dev, my-backend-service-url-qa 
Learn more at https://developer.atlassian.com/forge-content-security-and-egress-controls (requestId: c433e1ae706b4c279f6e035b635dcb4d)

I’m stuck on this for several hours - if not days - now and have searched everywhere in and outside this forum.

By the way, my backend API url is http, not https (at least not in dev).

Can anyone help, please?

Thank you.

Hi @LucasXavierFerreira. I’m fairly certain your endpoints need to have TLS implemented (https). I’m not aware of a way, but I’ll check to see if there’s any override available for development environment deployments.

1 Like

Doesn’t Forge support requests over non-safe http?
I mean, if my APIs don’t have https, then I just can’t call them from my Jira Cloud Forge app?

Hi @LucasXavierFerreira, that is correct, please see here for what is supported. As a workaround, if you really wanted to call an HTTP endpoint then one way to bypass this would be to implement a proxy yourself which exposes an HTTPS endpoint & proxies the request to the HTTP endpoint.