diff --git a/api/ovdashboard_api/main.py b/api/ovdashboard_api/main.py index 477ae0b..14bbf17 100644 --- a/api/ovdashboard_api/main.py +++ b/api/ovdashboard_api/main.py @@ -33,36 +33,36 @@ app = FastAPI( app.include_router(main_router) +if SETTINGS.production_mode: + # Mount frontend in production mode + app.mount( + path="/", + app=StaticFiles( + directory="/html", + html=True, + ), + name="frontend", + ) + +else: + # Allow CORS in debug mode + app.add_middleware( + CORSMiddleware, + allow_origins=[ + "*", + ], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], + expose_headers=["*"], + ) + def main() -> None: """ If the `main` script is run, `uvicorn` is used to run the app. """ - if SETTINGS.production_mode: - # Mount frontend in production mode - app.mount( - path="/", - app=StaticFiles( - directory="/html", - html=True, - ), - name="frontend", - ) - - else: - # Allow CORS in debug mode - app.add_middleware( - CORSMiddleware, - allow_origins=[ - "*", - ], - allow_credentials=True, - allow_methods=["*"], - allow_headers=["*"], - expose_headers=["*"], - ) - if webdav_check(): uvicorn_run( app="ovdashboard_api.main:app",