fix: use getContent() for JSON body parsing in log endpoint

This commit is contained in:
testadmin
2026-05-14 11:40:54 +08:00
parent 966b3133bf
commit df6aa119a0
2 changed files with 10 additions and 4 deletions
+5 -2
View File
@@ -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',
+5 -2
View File
@@ -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',