main.py 630 B

1234567891011121314151617181920
  1. from fastapi import FastAPI
  2. from starlette.middleware.cors import CORSMiddleware
  3. from app.api.api_v1.api import api_router
  4. from app.core.config import settings
  5. app = FastAPI(title=settings.PROJECT_NAME, openapi_url=f"{settings.API_V1_STR}/openapi.json")
  6. # Set all CORS enabled origins
  7. # allow_origins=[str(origin) for origin in settings.BACKEND_CORS_ORIGINS],
  8. if settings.BACKEND_CORS_ORIGINS:
  9. app.add_middleware(
  10. CORSMiddleware,
  11. allow_origins=["*"],
  12. allow_credentials=True,
  13. allow_methods=["*"],
  14. allow_headers=["*"],
  15. )
  16. app.include_router(api_router, prefix=settings.API_V1_STR)