Azure / Azure/static-web-apps

Redirect to login with `responseOverrides` doesn't come back to the requested page

Open
#735 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
346
Forks
67
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**

Redirect to the login page, forgets the previous path, and always returns to the home page.

All the pages in our app should be served to authenticated users. So instead of making a login button we automatically redirect all the users to the login page.

A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Use the `staticwebapp.config.json` below
2. Navigate to `/page1` page
3. It will redirect to the authentication page, authenticate
4. Instead of returning to `/page1` the app will return to `/` (index page)

```
{
"navigationFallback": {
"rewrite": "/index.html"
},
"routes": [
{
"route": "/*",
"allowedRoles": [
"authenticated"
]
}
],
"auth": {
"rolesSource": "/api/GetRoles",
"identityProviders": {
"azureActiveDirectory": {
"userDetailsClaim": "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name",
"registration": {
"openIdIssuer": "https://login.microsoftonline.com/XXXXXXXXXXXXXXXXXXXXXXXX",
"clientIdSettingName": "AAD_CLIENT_ID",
"clientSecretSettingName": "AAD_CLIENT_SECRET"
},
"login": {
"loginParameters": [
"resource=https://graph.microsoft.com"
]
}
}
}
},
"responseOverrides": {
"401": {
"redirect": "/.auth/login/aad",
"statusCode": 302
}
}
}
```

**Expected behavior**
Even with auth redirection with `responseOverrides` it should return to the originally requested page and not the index page.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Device info (if applicable):**
- OS: Windows 11
- Browser Chrome, Edge
- Version All

**Additional context**
Add any other context about the problem here.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.