Skip to content

Commit a5a335f

Browse files
committed
style: Refactor CORS configuration logic and improve formatting in main.py
1 parent 0ba7b95 commit a5a335f

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

backend/main.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
# Configure CORS origins based on environment
1010
# Check for production indicators
1111
is_production = (
12-
os.getenv("ENVIRONMENT") == "production" or
13-
os.getenv("GAE_APPLICATION") or # Google App Engine
14-
os.getenv("GOOGLE_CLOUD_PROJECT") or # Google Cloud
15-
os.getenv("K_SERVICE") # Google Cloud Run
12+
os.getenv("ENVIRONMENT") == "production"
13+
or os.getenv("GAE_APPLICATION") # Google App Engine
14+
or os.getenv("GOOGLE_CLOUD_PROJECT") # Google Cloud
15+
or os.getenv("K_SERVICE") # Google Cloud Run
1616
)
1717

1818
if is_production:
@@ -42,15 +42,17 @@
4242
allow_headers=["*"],
4343
)
4444

45+
4546
@app.get("/health")
4647
async def health_check():
4748
"""Health check endpoint that also shows CORS configuration."""
4849
return {
4950
"status": "healthy",
5051
"cors_production_mode": is_production,
51-
"cors_allowed_origins": allowed_origins
52+
"cors_allowed_origins": allowed_origins,
5253
}
5354

55+
5456
app.include_router(query.router, prefix="/query", tags=["Query"])
5557
app.include_router(azure.router, prefix="/azure", tags=["Azure"])
5658
app.include_router(system.router, prefix="/system", tags=["System"])

0 commit comments

Comments
 (0)