Fetching Data from External Backend in Forge

Hi everyone,

I need a bit of help with fetching data from my external backend in Forge. I’ve configured my manifest.yml file to allow access to the external backend as follows:

external:
  fetch:
    backend:
      - 1.something.somethingelse.cloud
      - api.ipify.org

const BASE_URL = “https://1.something.somethingelse.cloud:16567/api”;
However, when I try to fetch data using Forge’s fetch API, I receive a 403 error. Interestingly, if I don’t use Forge’s fetch and run it in tunnel mode, it works perfectly.

Here’s a snippet of my fetch function:

import { fetch } from '@forge/api';

const fetchData = async (endpoint) => {
  const url = `${BASE_URL}/${endpoint}`;
  const response = await fetch(url);
  if (!response.ok) {
    throw new Error(`HTTP error! Status: ${response.status}`);
  }
  return response.json();
};

Issues:
Receiving a 403 error when using Forge’s fetch API.
Works only in tunnel mode if Forge’s fetch is not used.
Could anyone provide insights on why this might be happening and how to resolve the 403 error when using Forge’s fetch API?

Thank you in advance for your help!

Welcome to the Atlassian developer community @MarkMathiasz1,

The short answer is that I think you have a forbidden port number.

From the Forge runtime docs about HTTPS only:

All external connections must be done through HTTPS; plain HTTP or TCP connections are not allowed. In addition, these connections will be implemented over a custom proxy which will only allow the following https.request options (or equivalents from third-party packages):

  • port
    • Only 80, 8080, 443, 8443, 8444, 7990, 8090, 8085 and 8060.

I’m not a dev on the tunnel feature, but I think making it more strict (to match the real Forge runtime) would only lead to more problems.

Thank you very much, it works! :partying_face: