From 2840561e2e7cec98c1d3719be5d7d5d2deb0de70 Mon Sep 17 00:00:00 2001 From: ArnabChatterjee20k Date: Thu, 5 Feb 2026 16:39:39 +0530 Subject: [PATCH] added loggings --- app/http.php | 18 ++++++++++++++++++ app/realtime.php | 11 +++++++++++ 2 files changed, 29 insertions(+) diff --git a/app/http.php b/app/http.php index 333f6d4de2..5c24b59afe 100644 --- a/app/http.php +++ b/app/http.php @@ -447,6 +447,24 @@ $http->on(Constant::EVENT_REQUEST, function (SwooleRequest $swooleRequest, Swool $request = new Request($swooleRequest); $response = new Response($swooleResponse); + // Debug incoming Origin header for HTTP requests + $origin = $request->getOrigin(); + if ($origin !== '') { + $originHost = \parse_url($origin, PHP_URL_HOST) ?: ''; + Console::warning( + '[HTTP][Origin] Incoming origin: ' . $origin . + ' (originHost=' . $originHost . + ', requestHost=' . $request->getHostname() . + ', uri=' . $request->getURI() . ')' + ); + } else { + Console::warning( + '[HTTP][Origin] No Origin header ' . + '(requestHost=' . $request->getHostname() . + ', uri=' . $request->getURI() . ')' + ); + } + if (Files::isFileLoaded($request->getURI())) { $time = (60 * 60 * 24 * 365 * 2); // 45 days cache diff --git a/app/realtime.php b/app/realtime.php index 1f0c4300a8..1831266fdc 100644 --- a/app/realtime.php +++ b/app/realtime.php @@ -607,9 +607,20 @@ $server->onOpen(function (int $connection, SwooleRequest $request) use ($server, * Skip this check for non-web platforms which are not required to send an origin header. */ $origin = $request->getOrigin(); + $originHost = \parse_url($origin, PHP_URL_HOST) ?: ''; + Console::warning( + '[Realtime][Origin] Incoming origin: ' . $origin . + ' (originHost=' . $originHost . + ', requestHost=' . $request->getHostname() . + ', projectId=' . $project->getId() . ')' + ); $originValidator = $app->getResource('originValidator'); if (!empty($origin) && !$originValidator->isValid($origin) && $project->getId() !== 'console') { + Console::warning( + '[Realtime][Origin] Origin failed validation: ' . $origin . + ' | reason="' . $originValidator->getDescription() . '"' + ); throw new Exception(Exception::REALTIME_POLICY_VIOLATION, $originValidator->getDescription()); }