Forge Fetch API

I want to call the API which runs in my localhost, port 9090 using the forge fetch API. But an error is thrown saying “Address not allowed”.

Code Snippet

const result = await fetch("https://localhost:9090/getData");
const status = result.status;

Error

{
  "message": "Address not allowed",
  "name": "FUNCTION_FETCH_ERR",
}

Is there any way to make a successful call to the API which runs on my localhost?

Yes, use a tool like ngrok. https://ngrok.com/

It’s a free tool that will set up web proxy to your localhost.

Does your Manifest include the external address as part of the Permissions? Like,

permissions:
  external:
    fetch:
      backend:
        - https://<ExternalAddress>.com
  scopes:

Are you importing fetch from @forge/api? If so, be aware that Forge functions don’t run in your browser but on a backend provided by Atlassian (see Runtime). So in general you won’t be able to access your localhost through fetch.

If you want to test your Forge app with a local API, use Ngrok or a similar tool to expose it (and add the resulting URL to your app’s permissions).