Added back X_REQUEST_ID, frankenphp doesn't include it by default.

This commit is contained in:
arabcoders
2025-05-18 00:10:11 +03:00
parent 31225e4148
commit 48cca385bb
2 changed files with 5 additions and 1 deletions

View File

@@ -57,6 +57,9 @@ set_exception_handler(function (Throwable $e) {
}); });
$factory = new Psr17Factory(); $factory = new Psr17Factory();
if (!isset($_SERVER['X_REQUEST_ID'])) {
$_SERVER['X_REQUEST_ID'] = generateUUID();
}
$request = new ServerRequestCreator($factory, $factory, $factory, $factory)->fromGlobals(); $request = new ServerRequestCreator($factory, $factory, $factory, $factory)->fromGlobals();
$profiler = new Profiler(callback: function (array $data) { $profiler = new Profiler(callback: function (array $data) {
$filter = function (array $data): array { $filter = function (array $data): array {
@@ -159,7 +162,7 @@ $exitCode = $profiler->process(function () use ($request) {
try { try {
// -- In case the frontend proxy does not generate request unique id. // -- In case the frontend proxy does not generate request unique id.
if (!isset($_SERVER['X_REQUEST_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(); $app = new App\Libs\Initializer()->boot();

View File

@@ -211,6 +211,7 @@ if (!function_exists('APIRequest')) {
'SERVER_NAME' => 'localhost', 'SERVER_NAME' => 'localhost',
'SERVER_PORT' => 80, 'SERVER_PORT' => 80,
'HTTP_USER_AGENT' => Config::get('http.default.options.headers.User-Agent', 'APIRequest'), 'HTTP_USER_AGENT' => Config::get('http.default.options.headers.User-Agent', 'APIRequest'),
'X_REQUEST_ID' => generateUUID('intr'),
...ag($opts, 'server', []), ...ag($opts, 'server', []),
]; ];