Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Commit
·
ba5d6d2
1
Parent(s):
e109700
Skip auth middleware for debug mode and HF Space container logs
Browse files- api/router.py +8 -0
api/router.py
CHANGED
@@ -12,6 +12,14 @@ router = APIRouter()
|
|
12 |
# Middleware d'authentification
|
13 |
async def verify_api_key(request: Request, call_next):
|
14 |
"""Middleware pour vérifier la clé API dans les en-têtes."""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
api_key = request.headers.get("x-api-key")
|
16 |
if api_key is None or api_key not in API_KEY.split(','):
|
17 |
logger.warning(f"Unauthorized API access attempt from {request.client.host}")
|
|
|
12 |
# Middleware d'authentification
|
13 |
async def verify_api_key(request: Request, call_next):
|
14 |
"""Middleware pour vérifier la clé API dans les en-têtes."""
|
15 |
+
# Skip if we're in debug mode or during startup
|
16 |
+
if os.environ.get("DEBUG") == "1":
|
17 |
+
return await call_next(request)
|
18 |
+
|
19 |
+
# Pour les routes Hugging Face Space (logs, etc.)
|
20 |
+
if request.url.path == "/" and "logs=container" in request.url.query:
|
21 |
+
return await call_next(request)
|
22 |
+
|
23 |
api_key = request.headers.get("x-api-key")
|
24 |
if api_key is None or api_key not in API_KEY.split(','):
|
25 |
logger.warning(f"Unauthorized API access attempt from {request.client.host}")
|