mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[PR #21216] [CLOSED] Fixed PWA 500 Error #64830
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?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/21216
Author: @Nitin75408
Created: 2/6/2026
Status: ❌ Closed
Base:
main← Head:Fixes/21072-PWA-Error📝 Commits (1)
402b41cFixed PWA 500 Error📊 Changes
7 files changed (+610 additions, -6 deletions)
View changed files
📝
backend/open_webui/main.py(+7 -0)➕
src/lib/apis/index.integration.test.ts(+155 -0)➕
src/lib/apis/index.test.ts(+215 -0)📝
src/lib/apis/index.ts(+35 -3)➕
src/lib/utils/index.test.ts(+116 -0)📝
src/lib/utils/index.ts(+59 -0)📝
src/routes/+layout.svelte(+23 -3)📄 Description
Pull Request Checklist
Note to first-time contributors: Please open a discussion post in Discussions to discuss your idea/fix with the community before creating a pull request, and describe your changes before submitting a pull request.
This is to ensure large feature PRs are discussed with the community first, before starting work on it. If the community does not want this feature or it is not relevant for Open WebUI as a project, it can be identified in the discussion before working on the feature and submitting the PR.
Before submitting, make sure you've checked the following:
devbranch. Not targeting thedevbranch will lead to immediate closure of the PR.Changelog Entry
Description
This pull request fixes a critical issue where Progressive Web Applications (PWAs) display a "500 Internal Server Error" page instead of redirecting to the external login page when the user's session expires with Trusted Header Auth or Forward Auth configurations (e.g., Authentik via Traefik).
The root cause was that when the PWA makes background API requests (such as
/api/config) on startup after session expiration, the reverse proxy correctly redirects to the external login page. However, browsers block these redirects in fetch requests due to CORS policy, causing the request to fail with a network error. The frontend was not handling this specific failure gracefully and instead displayed a generic error page.The solution implements proper detection of CORS-blocked authentication redirects and handles them by using
window.location.hrefto trigger the browser redirect, which allows the reverse proxy to complete the authentication flow seamlessly.Added
isAuthRedirectError()utility function insrc/lib/utils/index.tsto detect CORS and network errors that indicate authentication redirects being blocked by the browserhandleAuthRedirect()utility function to properly redirect the browser when authentication redirects are detectedsignout_redirect_urlfield to the backend config API response in the features object whenWEBUI_AUTH_SIGNOUT_REDIRECT_URLis configuredChanged
getBackendConfig()function insrc/lib/apis/index.tsto detect and handle CORS-blocked authentication redirect errors gracefully+layout.svelteto properly handle authentication redirect errors without displaying the error pageFixed
Test
isAuthRedirectError()function covering various error patterns (CORS errors, network failures, status codes)handleAuthRedirect()function covering redirect scenarios with and without signout URLsgetBackendConfig()function covering successful fetches, error handling, and signout URL storageAdditional Information
This fix addresses issue #21072 where users reported that PWAs installed on mobile devices (Android in particular) would show a 500 error page when launched after session expiration, instead of redirecting to the external authentication provider's login page.
The implementation works by:
window.location.hrefto redirect the browser, which allows redirects (unlike fetch API)The fix maintains backward compatibility and does not affect normal authentication flows. It only activates when CORS-blocked redirect errors are detected, ensuring that legitimate errors are still properly handled and displayed.
The backend now includes the
signout_redirect_urlin the config response whenWEBUI_AUTH_SIGNOUT_REDIRECT_URLenvironment variable is set, allowing the frontend to store it for future use even when the initial config fetch fails due to authentication redirects.Related Issue: #21072
Testing Performed:
WEBUI_AUTH_SIGNOUT_REDIRECT_URLconfiguredScreenshots or Videos
Before Fix:
When launching the PWA after session expiration, users would see a "500 Internal Server Error" page or "Open WebUI Backend Required" error page.
After Fix:
When launching the PWA after session expiration, the application seamlessly redirects to the external authentication provider's login page (e.g., Authentik), allowing users to authenticate and continue using the application.
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.