diff --git a/servers/fastapi/services/image_generation_service.py b/servers/fastapi/services/image_generation_service.py index a0159b68..33af29b8 100644 --- a/servers/fastapi/services/image_generation_service.py +++ b/servers/fastapi/services/image_generation_service.py @@ -111,7 +111,7 @@ class ImageGenerationService: return image_path async def get_image_from_pexels(self, prompt: str) -> str: - async with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession(trust_env=True) as session: response = await session.get( f"https://api.pexels.com/v1/search?query={prompt}&per_page=1", headers={"Authorization": f"{get_pexels_api_key_env()}"}, @@ -121,7 +121,7 @@ class ImageGenerationService: return image_url async def get_image_from_pixabay(self, prompt: str) -> str: - async with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession(trust_env=True) as session: response = await session.get( f"https://pixabay.com/api/?key={get_pixabay_api_key_env()}&q={prompt}&image_type=photo&per_page=3" ) diff --git a/servers/fastapi/utils/download_helpers.py b/servers/fastapi/utils/download_helpers.py index ef040af0..697a9394 100644 --- a/servers/fastapi/utils/download_helpers.py +++ b/servers/fastapi/utils/download_helpers.py @@ -19,7 +19,7 @@ async def download_file( filename = os.path.basename(parsed_url.path) if not filename or "." not in filename: - async with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession(trust_env=True) as session: async with session.head(url, headers=headers) as response: if response.status == 200: content_disposition = response.headers.get( @@ -41,7 +41,7 @@ async def download_file( filename = filename or get_random_uuid() save_path = os.path.join(save_directory, filename) - async with aiohttp.ClientSession() as session: + async with aiohttp.ClientSession(trust_env=True) as session: async with session.get(url, headers=headers) as response: if response.status == 200: with open(save_path, "wb") as file: