diff --git a/process.php b/process.php index c38cf9c..176f883 100755 --- a/process.php +++ b/process.php @@ -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);