added debug logging to process.php

This commit is contained in:
michael 2025-11-03 11:08:48 -06:00
parent b8a34d8b48
commit 78ece94513

View file

@ -28,19 +28,46 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_FILES['voiceFile'])) {
'target_lang' => $targetLanguage
];
// Build API URL
$apiUrl = PYTHON_API_URL . '/transcribe';
// DEBUG: Log the exact URL and configuration
error_log("=== UPLOAD DEBUG START ===");
error_log("PYTHON_API_URL constant: " . PYTHON_API_URL);
error_log("Full API URL: " . $apiUrl);
error_log("File name: " . $file['name']);
error_log("File size: " . $file['size']);
error_log("Output format: " . $outputFormat);
// Send request to Python API
$ch = curl_init(PYTHON_API_URL . '/transcribe');
$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $formData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 300); // 5 minutes timeout for large files
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$curlError = curl_error($ch);
$effectiveUrl = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
// DEBUG: Log response details
error_log("HTTP Code: " . $httpCode);
error_log("cURL Error: " . ($curlError ?: 'none'));
error_log("Effective URL: " . $effectiveUrl);
if ($httpCode === 301 || $httpCode === 302) {
$redirectUrl = curl_getinfo($ch, CURLINFO_REDIRECT_URL);
error_log("REDIRECT DETECTED!");
error_log("Redirect Location: " . ($redirectUrl ?: 'not provided'));
}
error_log("Response preview: " . substr($response, 0, 500));
error_log("=== UPLOAD DEBUG END ===");
if (curl_errno($ch)) {
echo json_encode(['success' => false, 'error' => "Error processing file: " . curl_error($ch)]);
} else {
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode === 200) {
$data = json_decode($response, true);