Intermittent 404 Errors with Azure Static Web App and Application Gateway

Prathap Dasari 45 Reputation points
2024-10-21T19:45:04.01+00:00

Hi Folks,

We are experiencing intermittent 404 errors when trying to access our Static Web App through our main DNS hostname behind an Azure Application Gateway. However, when we use the direct Static Web App URL, everything works as expected without any errors.

Current Setup:

Static Web App: Deployed and accessible via its Azure-generated URL (e.g., https://<appname>.azurestaticapps.net).

Application Gateway: Configured with a WAF policy and used for traffic routing, with a custom domain and DNS setup (e.g., https://www.mydomain.com).

DNS: Custom domain points to the Application Gateway's public IP.

Issue Details:

  • Problem: When accessing the Static Web App through our main custom domain (via the Application Gateway), the application works intermittently. It returns the expected data at times, but occasionally results in a 404 Not Found error.
  • No Issues with Static Web App URL: When accessing the Static Web App directly through the Azure-generated URL (<appname>.azurestaticapps.net), there are no 404 errors, and the application works perfectly.
  • Intermittent: The problem does not occur consistently. Sometimes the app loads fine, and sometimes it fails with a 404 error when accessed through the main DNS hostname.

Attempts to Resolve:

Cleared DNS caches: To rule out DNS resolution issues.

Checked Application Gateway Logs: We have inspected both the Access Logs and Firewall Logs, but haven't identified any consistent patterns causing the 404 errors.

Backend Health Monitoring: Shows the Static Web App backend as healthy in the Application Gateway.

Any advice or guidance would be much appreciated ?

Kr,

Prathap

Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,098 questions
Azure Web Application Firewall
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,021 questions
{count} votes

Accepted answer
  1. KapilAnanth-MSFT 48,081 Reputation points Microsoft Employee
    2024-10-22T15:00:51.8833333+00:00

    @Prathap Dasari ,

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this!

    Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others", I'll repost your solution.

    Please click "Accept" the answer as original posters help the community find answers faster by identifying the correct answer.

    Issue :

    Intermittent 404 Errors with Azure Static Web App and Application Gateway

    Resolution :

    • I suggested we check the Application Gateway Access Log
    • You informed us that there was a misconfiguration and two IP addresses were added to one hostname in DNS management ,
      • Which included the shared API Gateway's IP address.
      • When traffic was routed to the production API Gateway, everything worked fine.
      • However, when it was directed to the shared API Gateway, we were encountering 404 errors.
    • Post correcting this, the issue has been resolved.

    Cheers,

    Kapil


    Please don’t forget to close the thread by clicking "Accept the answer" wherever the information provided helps you, as this can be beneficial to other community members.

    1 person found this answer helpful.
    0 comments No comments

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.