Fix scanner/api communications

This commit is contained in:
Zoe Roux 2025-05-13 23:12:23 +02:00
parent c5d05d69aa
commit 0ef3348e9c
No known key found for this signature in database
2 changed files with 6 additions and 6 deletions

View File

@ -103,7 +103,9 @@ services:
ports:
- "4389:4389"
environment:
- KYOO_URL=${KYOO_URL:-http://api:3567/api}
# Use this env var once we use mTLS for auth
# - KYOO_URL=${KYOO_URL:-http://api:3567/api}
- KYOO_URL=${KYOO_URL:-http://traefik:8901/api}
- JWKS_URL=http://auth:4568/.well-known/jwks.json
- JWT_ISSUER=${PUBLIC_URL}
volumes:

View File

@ -15,17 +15,15 @@ logger = getLogger(__name__)
class KyooClient(metaclass=Singleton):
def __init__(self) -> None:
api_key = os.environ.get("KYOO_APIKEY")
if not api_key:
print("Missing environment variable 'KYOO_APIKEY'.")
exit(2)
self._client = ClientSession(
base_url=os.environ.get("KYOO_URL", "http://api:3567/api") + "/",
headers={
"User-Agent": "kyoo scanner v5",
"X-API-KEY": api_key,
"Content-type": "application/json",
},
)
if api_key := os.environ.get("KYOO_APIKEY"):
self._client.headers["X-API-KEY"] = api_key
async def __aenter__(self):
return self