From 09f0503d4b78027721bd7991f7f5556889ff320d Mon Sep 17 00:00:00 2001 From: Matheus Afonso Date: Mon, 20 Nov 2023 16:13:50 -0300 Subject: [PATCH] cors --- gestao/web/application.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gestao/web/application.py b/gestao/web/application.py index 2c65c6f..db77c4c 100644 --- a/gestao/web/application.py +++ b/gestao/web/application.py @@ -1,6 +1,7 @@ from importlib import metadata from fastapi import FastAPI +from fastapi.middleware.cors import CORSMiddleware from fastapi.responses import UJSONResponse from gestao.web.api.router import api_router @@ -24,6 +25,15 @@ def get_app() -> FastAPI: default_response_class=UJSONResponse, ) + origins = ["*"] + app.add_middleware( + CORSMiddleware, + allow_origins=origins, + allow_credentials=True, + allow_methods=["*"], + allow_headers=["*"], + ) + # Adds startup and shutdown events. register_startup_event(app) register_shutdown_event(app)