Static Web App page reloads returning 404 and not following the navigationFallback policy

Laura Jiménez Valencia 0 Puntos de reputación
2025-10-27T09:33:31.5033333+00:00

We have a SWA on Azure that returns a 404 Azure error page (on a page reload) instead of following the staticwebapp.config.json settings as described below:

{
  "navigationFallback": {
    "rewrite": "/index.html",
    "exclude": [
      "/data/*.json",
      "/img/*",
      "/fonts/*",
      "*.{css,js,map,png,jpg,jpeg,gif,ico,svg,webp,ttf,woff,woff2,eot,json}"
    ]
  },
  "routes": [
    {
      "route": "/contacto",
      "rewrite": "/index.html",
      "statusCode": 301,
      "allowedRoles": [
        "anonymous"
      ]
    }
  ]
}

The configuration file (staticwebapp.config.json) is in the root of the repository project.

The behavior:

  1. Load the SPA
  2. Navigate to some routes, notice no post back
  3. Do a full page reload, notice a post back
  4. See 404 azure page

Screenshot:

image

We have tried without adding the "routes" part in the file, and it does not work either.

Why is it not working?

Azure Static Web Apps
Azure Static Web Apps
Un servicio de Azure que proporciona el desarrollo optimizado de aplicaciones web de pila completa.
{count} votos

Su respuesta

Las respuestas pueden ser marcadas como "Aceptadas" por el autor de la pregunta y "Recomendadas" por los moderadores, lo que ayuda a los usuarios a saber que la respuesta ha resuelto el problema del autor.