I’m using SWA CLI to emulate an Azure Static Web App with an Angular application on my local machine. The staticwebapp.config.json file is used to protect specific routes. The current configuration works fine in the local emulator, but when publishing the application to Azure Static Web App, the “/test” route returns a 404 error.
This is my configuration on staticwebapp.config.json:
{
"navigationFallback": {
"rewrite": "/index.html"
},
"routes": [
{
"route": "/test",
"allowedRoles": ["authenticated"]
},
{
"route": "/.auth/login/github",
"statusCode": 404
},
{
"route": "/logout",
"redirect": "/.auth/logout"
}
],
"responseOverrides": {
"401": {
"statusCode": 302,
"redirect": "/.auth/login/aad"
}
}
}
}
Where the route “/test” matches with my angular route (app-routing.module.ts):
const routes: Routes = [
{
path: "analisys-results",
component: AnalisysResultsComponent,
},
{
path: "test",
component: TestProtectedComponent
},
{
path: "**",
redirectTo: "analisys-results"
}
];
In the emulator with SWA CLI it works fine on my local PC, but when publishing to Azure Static Web App the /test path returns 404
Note: this is with a business account from my work; However, I performed this same exercise with my personal account in Portal Azure and it works fine.
Aditional informations:
This screen is from my perosnal account with the same configuration, (Before that screen it asks me to log in with a Microsoft account):
I’m trying to access a protected route with staticwebapp.config.json file, and I’m expecting that it show the Microsoft Auth Page