mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 19:08:59 -05:00
Login breaks back button on Firefox, history -2 auth #2595
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Immortality-IMT on GitHub (Nov 8, 2024).
Bug Report
Installation Method: git clone, build a docker image, docker compose up
Expected Behavior:
The user has not logged in, so hitting auth the back button in Firefox bounces back to log in, rather it should go to the previous page.
Actual Behavior:
The user has not logged in, in auth hitting the back button bounces back to the login page.
Description
Hit the link on website1 and OpenWebUI auto logs in if creditials are saved, else it redirects to the login page. In Chrome hitting the back button returns to website1, in firefox it bounces, attempts to auto-login again and re-displays the login page. Hitting the back button then does not return to website1 but attempts to auto log in again and then re-redirects to the same login page and the back button gets stuck. This only occurs in Firefox and it is fixed in Chrome.
Make a html link and go to openwebui, make sure login creditials are not saved and then push the back button.
The issue is in the auth section of the code. In open webui when the their is no login it redirects to auth page and then pressing the back button keeps redirecting to the auth page and not going back -2, for instance, website1 -> opwenwebui -> no login redirects to auth page, back button repeat the redirect and does not return to website 1.
Check for Redirection Loops: Before redirecting to the /auth page, the code checks if the current path is already /auth. This prevents the redirection loop.
Use history.replaceState: Instead of just calling goto('/auth'), the code uses history.replaceState to replace the current history entry. This helps in maintaining the correct navigation stack.