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).