From 48cca385bbb5258896a0f7ac2168e9b214476810 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Sun, 18 May 2025 00:10:11 +0300 Subject: [PATCH] Added back X_REQUEST_ID, frankenphp doesn't include it by default. --- public/index.php | 5 ++++- src/Libs/Utils.php | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) 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', []), ];