I would redirect to the homepage again if the authentication failed because the authentication failed with basic authentication from ngnix, even if you canceled the cancellation and did not even try to authenticate.
If I do it as shown in the screenshot, it just loads the page; therefore redirection works, but authentication and therefore access to another page are no longer displayed. Do you know anything else that I could try?

source share