From 174cb75f23dafe0c94aae47f29700b8b876a0bde Mon Sep 17 00:00:00 2001 From: "Khoa.vo" Date: Tue, 13 Jan 2026 09:19:53 +0700 Subject: [PATCH] Add detailed cookie logging for debugging auth issues --- backend/routers/generate.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/routers/generate.py b/backend/routers/generate.py index 5c6592e..fda73f7 100644 --- a/backend/routers/generate.py +++ b/backend/routers/generate.py @@ -35,15 +35,27 @@ async def generate_images(request: GenerateRequest): try: # Normalize cookies if JSON format cookie_string = request.cookies.strip() + print(f"[Generate] Raw cookie input length: {len(cookie_string)} chars") + if cookie_string.startswith('[') or cookie_string.startswith('{'): import json try: cookie_array = json.loads(cookie_string) if isinstance(cookie_array, list): + # Log all cookie names for debugging + cookie_names = [c.get('name', '?') for c in cookie_array if isinstance(c, dict)] + print(f"[Generate] Parsed {len(cookie_array)} cookies: {cookie_names}") + + # Check for required Google cookies + required = ['SID', 'HSID', 'SSID', 'APISID', 'SAPISID'] + missing = [r for r in required if r not in cookie_names] + if missing: + print(f"[Generate] WARNING: Missing required cookies: {missing}") + cookie_string = "; ".join( f"{c['name']}={c['value']}" for c in cookie_array + if isinstance(c, dict) and 'name' in c and 'value' in c ) - print(f"[Generate] Parsed {len(cookie_array)} cookies from JSON.") except Exception as e: print(f"[Generate] Failed to parse cookie JSON: {e}")