Spaces:
Running
Running
fix(auth): call get_settings() inside verify_api_key — avoid stale module-level settings reference
Browse files- app/api/dependencies.py +3 -5
app/api/dependencies.py
CHANGED
|
@@ -1,13 +1,11 @@
|
|
| 1 |
from fastapi import Header, HTTPException
|
| 2 |
from typing import Optional
|
| 3 |
-
from app.core.config import get_settings
|
| 4 |
-
|
| 5 |
-
settings = get_settings()
|
| 6 |
-
|
| 7 |
|
| 8 |
def verify_api_key(x_api_key: Optional[str] = Header(default=None)) -> None:
|
|
|
|
| 9 |
if not settings.api_key:
|
| 10 |
-
import logging
|
| 11 |
logging.getLogger(__name__).warning(
|
| 12 |
"WARNING: API_KEY is not set — all endpoints are publicly accessible. "
|
| 13 |
"Set API_KEY in your .env or environment to enable authentication."
|
|
|
|
| 1 |
from fastapi import Header, HTTPException
|
| 2 |
from typing import Optional
|
| 3 |
+
from app.core.config import get_settings # keep import, remove module-level call
|
| 4 |
+
import logging
|
|
|
|
|
|
|
| 5 |
|
| 6 |
def verify_api_key(x_api_key: Optional[str] = Header(default=None)) -> None:
|
| 7 |
+
settings = get_settings() # ← call inside function
|
| 8 |
if not settings.api_key:
|
|
|
|
| 9 |
logging.getLogger(__name__).warning(
|
| 10 |
"WARNING: API_KEY is not set — all endpoints are publicly accessible. "
|
| 11 |
"Set API_KEY in your .env or environment to enable authentication."
|