diff --git a/api/config.php b/api/config.php index cb34a37..4341d44 100644 --- a/api/config.php +++ b/api/config.php @@ -76,8 +76,17 @@ function verifyToken($token) { // Fonction pour obtenir l'utilisateur actuel function getCurrentUser() { - $headers = getallheaders(); - $authHeader = $headers['Authorization'] ?? ''; + $authHeader = ''; + + // Détection universelle des headers d'autorisation + if (isset($_SERVER['HTTP_AUTHORIZATION'])) { + $authHeader = $_SERVER['HTTP_AUTHORIZATION']; + } elseif (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) { + $authHeader = $_SERVER['REDIRECT_HTTP_AUTHORIZATION']; + } elseif (function_exists('getallheaders')) { + $headers = getallheaders(); + $authHeader = $headers['Authorization'] ?? ''; + } if (preg_match('/Bearer\s+(.*)$/i', $authHeader, $matches)) { $token = $matches[1];