diff --git a/app/library/HttpAPI.py b/app/library/HttpAPI.py index c8ac7162..5f276f45 100644 --- a/app/library/HttpAPI.py +++ b/app/library/HttpAPI.py @@ -119,6 +119,7 @@ class HttpAPI(Common): HttpAPI: The instance of the HttpAPI. """ + app.middlewares.append(HttpAPI.middle_wares()) if self.config.auth_username and self.config.auth_password: app.middlewares.append(HttpAPI.basic_auth(self.config.auth_username, self.config.auth_password)) @@ -310,6 +311,24 @@ class HttpAPI(Common): return middleware_handler + @staticmethod + def middle_wares() -> Awaitable: + @web.middleware + async def middleware_handler(request: Request, handler: RequestHandler) -> Response: + response = await handler(request) + + if isinstance(response, web.FileResponse): + try: + ff_info = await ffprobe(response._path) + mime_type = get_mime_type(ff_info.get("metadata", {}), response._path) + response.content_type = mime_type + except Exception: + pass + + return response + + return middleware_handler + @route("OPTIONS", "/{path:.*}") async def add_coors(self, _: Request) -> Response: """ diff --git a/ui/layouts/default.vue b/ui/layouts/default.vue index 28eec019..fdc7bcc8 100644 --- a/ui/layouts/default.vue +++ b/ui/layouts/default.vue @@ -145,7 +145,13 @@ const applyPreferredColorScheme = scheme => { } } -watch(() => config.app.sentry_dsn, dsn => dsn ? Sentry.init({ dsn: dsn }) : null) +watch(() => config.app.sentry_dsn, dsn => { + if (!dsn) { + return + } + console.warn('Loading sentry module.') + Sentry.init({ dsn: dsn }) +}) onMounted(async () => { try {