getMessage()); } // Gestione dell'output $output = ob_get_clean(); $response = response($output); // Fix content-type per contenuti non HTML if (ends_with($path, '.js')) { $response = $response->header('Content-Type', 'application/javascript'); } elseif (string_contains($path, 'pdfgen.php')) { $response = $response->header('Content-Type', 'application/pdf'); } elseif ($api_request) { $response = $response->header('Content-Type', 'application/json'); } return $response; } }