.referrer in responseOverrides redirect is not working for custom urls
- Dominant language
- No language data
- Stars
- 346
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
The responseOverrides only replaces the .referrer keyword when the base path is in `/.auth`, if we use any other path, the `.referrer` is not replaced.
I have created a custom page for letting the user select the login provider (Microsoft, GitHub, Google,...). When running the page in the local environment the responseOverrides replaces the .referrer keyword by the referrer page, but when deploying it to the static web app this stops working.
**To Reproduce**
Steps to reproduce the behavior:
Use a response override with a custom page (out of the /.auth path) and add the .referrer keyword to get the referrer in the query:
```json
"responseOverrides": {
"401": {
"statusCode": 302,
"redirect": "/sso?post_login_redirect_uri=.referrer"
}
},
```
**Expected behavior**
Replace the `.referrer` keyword in any responseOverrides configuration with redirect.
**Screenshots**
When using any /.auth path the .referrer keyword is correctly replaced:

When using custom path the .referrer keyword is left as is:

When using the local swa emulator, it works as expected replacing the .referrer keyword even for custom pages:

**Why do I need this?**
I've configured a few different auth providers (aad, google & github) and I want a bridge page to let the user choose its preferred authentication method, just like this:
But when using this intermediate page that redirects to the /.auth/login/[provider] , the `.referrer` is not replaced.
Is there any other way to achieve this?
**Partial workaround**
I can store the link using localStorage during the `beforeunload` event:
```js
window.onbeforeunload = function () {
localStorage.setItem('lastPage', document.activeElement.href);
};
```
And then check if the `.referrer` has been replaced or not and use this value, but this only works if the user comes from a link in the same website, it won't work for external links.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.