fix: parse JSON body in log report endpoint

This commit is contained in:
testadmin
2026-05-14 11:38:59 +08:00
parent 817e262140
commit 966b3133bf
2 changed files with 4 additions and 2 deletions
+2 -1
View File
@@ -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',
+2 -1
View File
@@ -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',