diff --git a/public/index.php b/public/index.php index 45d9211b..6a555c9b 100644 --- a/public/index.php +++ b/public/index.php @@ -57,6 +57,9 @@ set_exception_handler(function (Throwable $e) { }); $factory = new Psr17Factory(); +if (!isset($_SERVER['X_REQUEST_ID'])) { + $_SERVER['X_REQUEST_ID'] = generateUUID(); +} $request = new ServerRequestCreator($factory, $factory, $factory, $factory)->fromGlobals(); $profiler = new Profiler(callback: function (array $data) { $filter = function (array $data): array { @@ -159,7 +162,7 @@ $exitCode = $profiler->process(function () use ($request) { try { // -- In case the frontend proxy does not generate request unique id. if (!isset($_SERVER['X_REQUEST_ID'])) { - $_SERVER['X_REQUEST_ID'] = bin2hex(random_bytes(16)); + $_SERVER['X_REQUEST_ID'] = generateUUID(); } $app = new App\Libs\Initializer()->boot(); diff --git a/src/Libs/Utils.php b/src/Libs/Utils.php index 63603a4f..da327535 100644 --- a/src/Libs/Utils.php +++ b/src/Libs/Utils.php @@ -211,6 +211,7 @@ if (!function_exists('APIRequest')) { 'SERVER_NAME' => 'localhost', 'SERVER_PORT' => 80, 'HTTP_USER_AGENT' => Config::get('http.default.options.headers.User-Agent', 'APIRequest'), + 'X_REQUEST_ID' => generateUUID('intr'), ...ag($opts, 'server', []), ];