Can't reach my nodejs azure app service api from my angular azure static web app. Got a 404 in the browser's console.

yodil 20 Reputation points
2023-07-05T17:52:49.9566667+00:00

Can't reach my nodejs azure app service api from my angular azure static web app. Got a 404 in the browser's console. The url stated in the console's error message has this form: "url-static-web-app/url-app-service/route". The "url-static-web-app" is concatenated by azure.

This is the code I use to make the call:

 this.httpClient.get<ILog[]>(`url-app-service/logs`)


What is wrong? I already tested that the nodejs app service is up and running by making requests with postman. I thought maybe I cannot chose my own backend since I use the student subscription.

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
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,173 questions
{count} votes

Accepted answer
  1. ajkuma 28,036 Reputation points Microsoft Employee Moderator
    2023-07-07T10:12:00.68+00:00

    Apologies for the delay. Based on my understanding of your issue, typically, the error message you're seeing in the browser's console indicates that the URL being used to make the API call is incorrect it's possible that the URL is not being constructed correctly in your Angular app.

    Are you referring to this doc for the steps?  As mentioned in the doc - when you link your Azure App Service web app to your static web app, any requests to your static web app with a route that starts with /api are proxied to the same route on the Azure App Service.

    If you haven’t tried, just to isolate - try "https://<app-service-name>.azurewebsites.net/api/logs". Replace <app-service-name> with the name of your Azure App Service.

    this.httpClient.get<ILog[]>(https://<app-service-name>.azurewebsites.net/api/logs)

     

    Also, verify that your Node.js API is configured to accept requests from your Azure Static Web App. You can do this by checking the CORS settings in your Node.js app.

    Regarding your concern about using your own backend with a student subscription, there are no restrictions on using your own backend with a student subscription. However, there are some limitations on the resources that are available to you with a student subscription. You may check the Azure for Students FAQ for more information on these limitations.

    Please let us know, I'll follow-up with you further.

    1 person found this answer helpful.

0 additional answers

Sort by: Most 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.