From 480587d3c1635685567bac73a569207b3465ea76 Mon Sep 17 00:00:00 2001 From: JR Boos Date: Tue, 8 Jul 2025 12:06:55 -0400 Subject: [PATCH] Add CORS middleware to FastAPI application This update introduces the CORSMiddleware to the FastAPI application, allowing cross-origin requests from any origin. The middleware is configured to accept all methods and headers, enhancing the application's flexibility in handling requests from different clients. --- src/app/main.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/app/main.py b/src/app/main.py index c315136f..90c09446 100644 --- a/src/app/main.py +++ b/src/app/main.py @@ -1,6 +1,7 @@ """Definition of FastAPI based web service.""" from fastapi import FastAPI +from fastapi.middleware.cors import CORSMiddleware from app import routers import version @@ -25,6 +26,14 @@ }, ) +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) + logger.info("Including routers") routers.include_routers(app)