From bbcbbca8d8f1f870dacffcf538511857ce4b64e6 Mon Sep 17 00:00:00 2001 From: Matthias Seghers Date: Tue, 12 Mar 2024 16:51:19 +0100 Subject: [PATCH] added debug options to make dev life easier --- backend/app.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/backend/app.py b/backend/app.py index 1ec9e990..eeee0710 100644 --- a/backend/app.py +++ b/backend/app.py @@ -23,6 +23,23 @@ app.include_router(subject_router, prefix="/api") app.include_router(group_router, prefix="/api") +DEBUG = False # Should always be false in repo + +if DEBUG: + from fastapi.middleware.cors import CORSMiddleware + origins = [ + "https://localhost", + "https://localhost:8080", + "http://localhost:5173" + ] + + app.add_middleware( + CORSMiddleware, + allow_origins=origins, + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], + ) # Koppel de exception handlers @app.exception_handler(InvalidRoleCredentialsError)