update FastAPI middleware configuration and change server command to use Uvicorn

This commit is contained in:
2025-09-02 05:32:42 +03:00
parent e8c776ac66
commit cc45da84d1
2 changed files with 8 additions and 11 deletions

17
main.py
View File

@@ -12,9 +12,6 @@ from constants import API_ROOT
from external.kafka import consume_messages
from external.kafka.producer import init_producer, get_producer
origins = [
'http://localhost:5173'
]
@asynccontextmanager
@@ -38,13 +35,13 @@ async def lifespan(app: FastAPI):
app = FastAPI(lifespan=lifespan, separate_input_output_schemas=False, root_path='/api')
app.add_middleware(
CORSMiddleware,
allow_origins=origins,
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
# app.add_middleware(
# CORSMiddleware,
# allow_origins=origins,
# allow_credentials=True,
# allow_methods=["*"],
# allow_headers=["*"],
# )
routers_list = [
routers.attribute_router,

2
start_fastapi.sh Normal file → Executable file
View File

@@ -1 +1 @@
gunicorn main:app -w 4
uvicorn main:app --host 0.0.0.0 --port 8000 --workers 4