Yadav122 commited on
Commit
cb2a233
·
1 Parent(s): 174e199
Files changed (1) hide show
  1. app/main.py +16 -3
app/main.py CHANGED
@@ -1,5 +1,6 @@
1
  """Main FastAPI app instance declaration."""
2
  import fastapi
 
3
  import structlog
4
  import uvicorn
5
 
@@ -10,16 +11,28 @@ from app.router import api_router
10
  # Set up structlog for logging
11
  logger = structlog.get_logger()
12
 
13
-
14
  fastapi_app = fastapi.FastAPI(
15
  title=settings.PROJECT_NAME,
16
  version=settings.VERSION,
17
  description=settings.DESCRIPTION,
18
- openapi_url=settings.OPENAPI_URL,
19
- docs_url=settings.DOCS_URL,
 
 
 
 
 
 
 
 
 
 
20
  )
 
21
  fastapi_app.include_router(api_router)
22
  add_middlewares(fastapi_app)
 
23
  # Log the app startup
24
  logger.info(
25
  "Application started", project=settings.PROJECT_NAME, version=settings.VERSION
 
1
  """Main FastAPI app instance declaration."""
2
  import fastapi
3
+ from fastapi.middleware.cors import CORSMiddleware
4
  import structlog
5
  import uvicorn
6
 
 
11
  # Set up structlog for logging
12
  logger = structlog.get_logger()
13
 
14
+ # Create FastAPI app with explicit paths
15
  fastapi_app = fastapi.FastAPI(
16
  title=settings.PROJECT_NAME,
17
  version=settings.VERSION,
18
  description=settings.DESCRIPTION,
19
+ openapi_url="/openapi.json", # Explicit path
20
+ docs_url="/docs", # Explicit path
21
+ redoc_url="/redoc", # Explicit path
22
+ )
23
+
24
+ # Add CORS middleware directly
25
+ fastapi_app.add_middleware(
26
+ CORSMiddleware,
27
+ allow_origins=["*"],
28
+ allow_credentials=True,
29
+ allow_methods=["*"],
30
+ allow_headers=["*"],
31
  )
32
+
33
  fastapi_app.include_router(api_router)
34
  add_middlewares(fastapi_app)
35
+
36
  # Log the app startup
37
  logger.info(
38
  "Application started", project=settings.PROJECT_NAME, version=settings.VERSION