diff --git a/app/handle/controller/Log.php b/app/handle/controller/Log.php index 5037bb9..de61361 100644 --- a/app/handle/controller/Log.php +++ b/app/handle/controller/Log.php @@ -11,8 +11,11 @@ class Log public function report(): Json { if (!Request::instance()->isPost()) return json(['status' => 0]); - $raw = file_get_contents('php://input'); - $data = json_decode($raw, true) ?: Request::instance()->post(); + $data = Request::instance()->post(); + if (empty($data)) { + $raw = Request::instance()->getContent(); + $data = json_decode($raw, true) ?: []; + } \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 8062ef5..a6147ec 100644 --- a/app/index/controller/Log.php +++ b/app/index/controller/Log.php @@ -11,8 +11,11 @@ class Log public function report(): Json { if (!Request::instance()->isPost()) return json(['status' => 0]); - $raw = file_get_contents('php://input'); - $data = json_decode($raw, true) ?: Request::instance()->post(); + $data = Request::instance()->post(); + if (empty($data)) { + $raw = Request::instance()->getContent(); + $data = json_decode($raw, true) ?: []; + } \app\utils\Logger::error(\app\utils\Logger::CAT_FRONTEND, $data['message'] ?? 'unknown', [ 'source' => $data['source'] ?? 'unknown', 'type' => $data['type'] ?? 'error',