Web App hosted on Azure unable to fetch data from API (Failed to load resource: net::ERR_CONNECTION_REFUSED)

brian3190 11 Reputation points
2022-06-14T01:07:09.547+00:00

I hosted a React App on Azure but it is unable to fetch data from the API. I've also hosted the SQL database on Azure SQL backend and changed the connection strings on the Web App to match it. Why is the React App still unable to fetch data?

Failed to load resource: net::ERR_CONNECTION_REFUSED: https://freeimage.host/i/h7iI2f

WeatherForecastcontroller API is able to fetch data from hardcoded array: https://freeimage.host/i/h7i91a

This is my Fetch API source URI saved in .env file: https://freeimage.host/i/h7iOEg
https://onboarding2.azurewebsites.net/api/customers

Postman is returning data from API: https://freeimage.host/i/h7ssDB

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,933 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jaliya Udagedara 2,836 Reputation points MVP Volunteer Moderator
    2022-06-14T06:35:52.707+00:00

    Your client app is calling localhost and it won't work.
    211201-image.png

    Please set the correct value for this environment variable. In your case: it's https://onboarding2.azurewebsites.net/api/
    211164-image.png

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.