From ce70045dac251ede9e308d1cb5a63d80bd2b87ea Mon Sep 17 00:00:00 2001 From: "Victor R. Santos" Date: Sun, 20 Mar 2022 12:21:09 +0000 Subject: [PATCH] Fix Error `404 Not Found` for Static Files (#124) After changing for FastAPI the server ignores STATIC_ROOT and STATIC_URL --- etebase_fastapi/main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/etebase_fastapi/main.py b/etebase_fastapi/main.py index d63c01d..3e0c1e9 100644 --- a/etebase_fastapi/main.py +++ b/etebase_fastapi/main.py @@ -4,6 +4,7 @@ from django.conf import settings from fastapi import FastAPI, Request from fastapi.middleware.cors import CORSMiddleware from fastapi.middleware.trustedhost import TrustedHostMiddleware +from fastapi.staticfiles import StaticFiles from django_etebase import app_settings @@ -74,4 +75,6 @@ def create_application(prefix="", middlewares=[]): async def custom_exception_handler(request: Request, exc: CustomHttpException): return MsgpackResponse(status_code=exc.status_code, content=exc.as_dict) + app.mount(settings.STATIC_URL, StaticFiles(directory=settings.STATIC_ROOT), name="static") + return app