From c12f8d28b9bef1107e614ce19341deef4c2ca099 Mon Sep 17 00:00:00 2001 From: Kurt Heiden Date: Thu, 10 Apr 2025 11:35:43 -0600 Subject: [PATCH] Add PWA external manifest URL env var --- backend/open_webui/env.py | 7 ++++++ backend/open_webui/main.py | 51 +++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/backend/open_webui/env.py b/backend/open_webui/env.py index 49aee4457..ba1094d51 100644 --- a/backend/open_webui/env.py +++ b/backend/open_webui/env.py @@ -474,3 +474,10 @@ OTEL_TRACES_SAMPLER = os.environ.get( PIP_OPTIONS = os.getenv("PIP_OPTIONS", "").split() PIP_PACKAGE_INDEX_OPTIONS = os.getenv("PIP_PACKAGE_INDEX_OPTIONS", "").split() + + +#################################### +# PROGRESSIVE WEB APP OPTIONS +#################################### + +EXTERNAL_PWA_MANIFEST_URL = os.environ.get("EXTERNAL_PWA_MANIFEST_URL") \ No newline at end of file diff --git a/backend/open_webui/main.py b/backend/open_webui/main.py index 5c5d86eb1..5988f9528 100644 --- a/backend/open_webui/main.py +++ b/backend/open_webui/main.py @@ -340,6 +340,7 @@ from open_webui.env import ( RESET_CONFIG_ON_START, OFFLINE_MODE, ENABLE_OTEL, + EXTERNAL_PWA_MANIFEST_URL, ) @@ -564,6 +565,7 @@ app.state.config.LDAP_CIPHERS = LDAP_CIPHERS app.state.AUTH_TRUSTED_EMAIL_HEADER = WEBUI_AUTH_TRUSTED_EMAIL_HEADER app.state.AUTH_TRUSTED_NAME_HEADER = WEBUI_AUTH_TRUSTED_NAME_HEADER +app.state.EXTERNAL_PWA_MANIFEST_URL = EXTERNAL_PWA_MANIFEST_URL app.state.USER_COUNT = None app.state.TOOLS = {} @@ -1393,29 +1395,32 @@ async def oauth_callback(provider: str, request: Request, response: Response): @app.get("/manifest.json") async def get_manifest_json(): - return { - "name": app.state.WEBUI_NAME, - "short_name": app.state.WEBUI_NAME, - "description": "Open WebUI is an open, extensible, user-friendly interface for AI that adapts to your workflow.", - "start_url": "/", - "display": "standalone", - "background_color": "#343541", - "orientation": "natural", - "icons": [ - { - "src": "/static/logo.png", - "type": "image/png", - "sizes": "500x500", - "purpose": "any", - }, - { - "src": "/static/logo.png", - "type": "image/png", - "sizes": "500x500", - "purpose": "maskable", - }, - ], - } + if app.state.EXTERNAL_PWA_MANIFEST_URL: + return requests.get(app.state.EXTERNAL_PWA_MANIFEST_URL).json() + else: + return { + "name": app.state.WEBUI_NAME, + "short_name": app.state.WEBUI_NAME, + "description": "Open WebUI is an open, extensible, user-friendly interface for AI that adapts to your workflow.", + "start_url": "/", + "display": "standalone", + "background_color": "#343541", + "orientation": "natural", + "icons": [ + { + "src": "/static/logo.png", + "type": "image/png", + "sizes": "500x500", + "purpose": "any", + }, + { + "src": "/static/logo.png", + "type": "image/png", + "sizes": "500x500", + "purpose": "maskable", + }, + ], + } @app.get("/opensearch.xml")