File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,19 @@ async def lifespan(app: FastAPI):
6868 await enedis_adapter .close ()
6969
7070
71+ def get_servers ():
72+ """Build servers list for OpenAPI based on configuration."""
73+ servers = [
74+ {"url" : "/api" , "description" : "API via proxy (relative)" },
75+ ]
76+ # Add production server if FRONTEND_URL is configured
77+ if settings .FRONTEND_URL and settings .FRONTEND_URL != "http://localhost:3000" :
78+ servers .insert (0 , {"url" : f"{ settings .FRONTEND_URL } /api" , "description" : "Production API" })
79+ # Add local dev server
80+ servers .append ({"url" : "http://localhost:8000" , "description" : "Backend direct (dev)" })
81+ return servers
82+
83+
7184app = FastAPI (
7285 title = "MyElectricalData API" ,
7386 description = "API Gateway for Enedis data access" ,
@@ -76,10 +89,7 @@ async def lifespan(app: FastAPI):
7689 docs_url = "/docs" , # Use default docs
7790 root_path = "/api" ,
7891 redoc_url = "/redoc" ,
79- servers = [
80- {"url" : "/api" , "description" : "API via proxy" },
81- {"url" : "http://localhost:8000" , "description" : "Backend direct" },
82- ],
92+ servers = get_servers (),
8393 swagger_ui_init_oauth = {
8494 "clientId" : "" ,
8595 "usePkceWithAuthorizationCodeGrant" : False ,
You can’t perform that action at this time.
0 commit comments