[Bug] Navigation fallback ignores configured routes allowedRoles
- Dominant language
- No language data
- Stars
- 346
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Using the following staticwebapp.config.json, if the navigation fallback rule is activated the allowedRoles setting for the '/index.html' route is ignored and the file is served to anonymous users. Directly navigating to /index.html or /index.js works as expected and properly redirects to the login page.
```json
{
"routes": [
{
"route": "/login",
"rewrite": "/login.html"
},
{
"route": "/index*.{js,html}",
"allowedRoles": [
"authenticated"
]
}
],
"navigationFallback": {
"rewrite": "/index.html"
},
"responseOverrides": {
"401": {
"redirect": "/login",
"statusCode": 302
}
}
}
```
It should be noted this is only the case for a deployed SWA, in the local emulator this works as expected and the fallback is properly redirected.
**Expected behavior**
Navigation fallback respects the 'allowedRoles' of configured routes, so that anonymous users are always redirected to /login following the reponseOverrides rule.
**Additional context**
I'm running a SPA that I want to secure behind a static login page in order to prevent unauthorized access to the html/js code. For convenience sake the login page is reusing the styling of the application, but it also needs to serve things like a favicon/manifest.json so I can't use a catch-all route with the allowedRoles set to 'authenticated', but I'd also expect such a route to still be ignored by the fallback.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.