diff options
author | Anderson Shindy Oki <[email protected]> | 2024-07-08 10:32:11 +0900 |
---|---|---|
committer | GitHub <[email protected]> | 2024-07-08 10:32:11 +0900 |
commit | 0f14a33c7354df57054c7c1b56dc0746ec4fce3e (patch) | |
tree | b165ca37faa5da6b91509ad152a5047fc69c2efa | |
parent | 40985fdee3bdfd722d160f04621a6294732a49d0 (diff) | |
download | bazarr-0f14a33c7354df57054c7c1b56dc0746ec4fce3e.tar.gz bazarr-0f14a33c7354df57054c7c1b56dc0746ec4fce3e.zip |
Fixed pwa assets files not served (#2568)
-rw-r--r-- | bazarr/app/ui.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/bazarr/app/ui.py b/bazarr/app/ui.py index 81a949035..79649e30e 100644 --- a/bazarr/app/ui.py +++ b/bazarr/app/ui.py @@ -20,9 +20,10 @@ from .config import settings, base_url from .database import System from .get_args import args +frontend_build_path = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'frontend', 'build') + ui_bp = Blueprint('ui', __name__, - template_folder=os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), - 'frontend', 'build'), + template_folder=frontend_build_path, static_folder=os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'frontend', 'build', 'assets'), static_url_path='/assets') @@ -38,13 +39,15 @@ static_bp = Blueprint('images', __name__, static_folder=static_directory, static ui_bp.register_blueprint(static_bp) - mimetypes.add_type('application/javascript', '.js') mimetypes.add_type('text/css', '.css') mimetypes.add_type('font/woff2', '.woff2') mimetypes.add_type('image/svg+xml', '.svg') mimetypes.add_type('image/png', '.png') mimetypes.add_type('image/x-icon', '.ico') +mimetypes.add_type('application/manifest+json', '.webmanifest') + +pwa_assets = ['registerSW.js', 'manifest.webmanifest', 'sw.js'] def check_login(actual_method): @@ -70,6 +73,10 @@ def catch_all(path): # login page has been accessed when no authentication is enabled return redirect(base_url or "/", code=302) + # PWA Assets are returned from frontend root folder + if path in pwa_assets or path.startswith('workbox-'): + return send_file(os.path.join(frontend_build_path, path)) + auth = True if settings.auth.type == 'basic': auth = request.authorization @@ -186,7 +193,8 @@ def proxy(protocol, url): elif result.status_code == 401: return dict(status=False, error='Access Denied. Check API key.', code=result.status_code) elif result.status_code == 404: - return dict(status=False, error='Cannot get version. Maybe unsupported legacy API call?', code=result.status_code) + return dict(status=False, error='Cannot get version. Maybe unsupported legacy API call?', + code=result.status_code) elif 300 <= result.status_code <= 399: return dict(status=False, error='Wrong URL Base.', code=result.status_code) else: |