Getting error when trying to call API inside Web App through another Web App - Azure

469 views Asked by At

I have two Web Apps, inside the same App Service. One is a back-end portion (with API on it, using .NET Core, SSL cert installed) and the other one is the front-end (ReactTS, created using create-react-app).

When I try to call the API method (an Auth method) using my Front-end I got this message as response:

Login failed: The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.

-404 error

Another fact is, if I run my ront-end solution locally, I can use the API (published on the Web App), normally.

My API URL is set inside the package.json file, as proxy.

My first thought was about an CORS problem, but it throws a 404 error.

Any configuration that I can do on my Azure, or something that I need to change in my application to allow my front-end to communicate with my API?

1

There are 1 answers

0
Amor On BEST ANSWER

If we publish two web applications to one Azure Web App, the later one will cover the first one. It will cause that the first web application can't work. I suggest you create different Azure Web Apps for your web applications. You could choose one Azure Web App Plan for your Azure Web Apps. It will not add extra costs except for Shared plan.

If you use Shared App Plan and don't want to increase the extra cost, you could add a virtual directory to your Azure Web App. Then you could publish your second web application to the virtual directory. To create a virtual directory, steps below are for your reference.

Azure portal -> Web App Panel -> Application settings

enter image description here