<?php
// api/auth/debug-headers.php

header('Content-Type: application/json');

$headers = [];
foreach ($_SERVER as $key => $value) {
    if (strpos($key, 'HTTP_') === 0) {
        $header = str_replace(' ', '-', ucwords(str_replace('_', ' ', strtolower(substr($key, 5)))));
        $headers[$header] = $value;
    }
}

echo json_encode([
    'all_server_keys' => array_keys($_SERVER),
    'headers' => $headers,
    'authorization_from_server' => $_SERVER['HTTP_AUTHORIZATION'] ?? null,
    'authorization_from_redirect' => $_SERVER['REDIRECT_HTTP_AUTHORIZATION'] ?? null,
    'raw_authorization' => $_SERVER['Authorization'] ?? null
], JSON_PRETTY_PRINT);
?>