From 2a1f3af9608ff736561a805594c93a8177ff560b Mon Sep 17 00:00:00 2001 From: Philipp Spinnler Date: Wed, 18 Sep 2024 10:01:41 +0200 Subject: [PATCH] added cors support --- app/main.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/main.py b/app/main.py index 4dd98f5..cbb4a5f 100644 --- a/app/main.py +++ b/app/main.py @@ -13,6 +13,7 @@ from fastapi_cache import FastAPICache from fastapi_cache.backends.inmemory import InMemoryBackend from fastapi_cache.decorator import cache +from fastapi.middleware.cors import CORSMiddleware @asynccontextmanager @@ -22,6 +23,13 @@ async def lifespan(_: FastAPI) -> AsyncIterator[None]: app = FastAPI(lifespan=lifespan) +app.add_middleware( + CORSMiddleware, + allow_origins=["*"], + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], +) @app.get("/")