From 966b3133bf582e22838a7e212893b990f55a7e17 Mon Sep 17 00:00:00 2001 From: testadmin Date: Thu, 14 May 2026 11:38:59 +0800 Subject: [PATCH] fix: parse JSON body in log report endpoint --- app/handle/controller/Log.php | 3 ++- app/index/controller/Log.php | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/handle/controller/Log.php b/app/handle/controller/Log.php index 7f3622a..5037bb9 100644 --- a/app/handle/controller/Log.php +++ b/app/handle/controller/Log.php @@ -11,7 +11,8 @@ class Log public function report(): Json { if (!Request::instance()->isPost()) return json(['status' => 0]); - $data = Request::instance()->post(); + $raw = file_get_contents('php://input'); + $data = json_decode($raw, true) ?: Request::instance()->post(); \app\utils\Logger::error(\app\utils\Logger::CAT_FRONTEND, $data['message'] ?? 'unknown', [ 'source' => $data['source'] ?? 'unknown', 'type' => $data['type'] ?? 'error', diff --git a/app/index/controller/Log.php b/app/index/controller/Log.php index 8c367fc..8062ef5 100644 --- a/app/index/controller/Log.php +++ b/app/index/controller/Log.php @@ -11,7 +11,8 @@ class Log public function report(): Json { if (!Request::instance()->isPost()) return json(['status' => 0]); - $data = Request::instance()->post(); + $raw = file_get_contents('php://input'); + $data = json_decode($raw, true) ?: Request::instance()->post(); \app\utils\Logger::error(\app\utils\Logger::CAT_FRONTEND, $data['message'] ?? 'unknown', [ 'source' => $data['source'] ?? 'unknown', 'type' => $data['type'] ?? 'error',