true, 'user' => [ 'name' => 'User', 'preferred_username' => 'anonymous@nano-banana-pro.com' ] ]; // Check authentication (with graceful fallback) try { if (file_exists(__DIR__ . '/AuthMiddleware.php')) { require_once 'AuthMiddleware.php'; $auth = new AuthMiddleware(); $authStatus = $auth->isAuthenticated(); if (!$authStatus['authenticated']) { http_response_code(401); echo json_encode([ 'success' => false, 'error' => 'Authentication required' ]); exit; } } } catch (Exception $e) { // Log error but continue without auth (for testing) error_log("Auth check failed in get_current_image.php: " . $e->getMessage()); } try { // Get current image from session $currentImage = $sessionManager->getCurrentImage(); if ($currentImage) { echo json_encode([ 'success' => true, 'data' => $currentImage['data'], 'mime_type' => $currentImage['mime_type'] ]); } else { echo json_encode([ 'success' => false, 'error' => 'No image in current session' ]); } } catch (Exception $e) { http_response_code(500); echo json_encode([ 'success' => false, 'error' => $e->getMessage() ]); }