mirror of
https://github.com/morpheus65535/bazarr.git
synced 2024-11-10 09:02:44 +08:00
Fixed pwa assets files not served (#2568)
This commit is contained in:
parent
40985fdee3
commit
0f14a33c73
1 changed files with 12 additions and 4 deletions
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue