fix: use getContent() for JSON body parsing in log endpoint
This commit is contained in:
@@ -11,8 +11,11 @@ class Log
|
|||||||
public function report(): Json
|
public function report(): Json
|
||||||
{
|
{
|
||||||
if (!Request::instance()->isPost()) return json(['status' => 0]);
|
if (!Request::instance()->isPost()) return json(['status' => 0]);
|
||||||
$raw = file_get_contents('php://input');
|
$data = Request::instance()->post();
|
||||||
$data = json_decode($raw, true) ?: 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', [
|
\app\utils\Logger::error(\app\utils\Logger::CAT_FRONTEND, $data['message'] ?? 'unknown', [
|
||||||
'source' => $data['source'] ?? 'unknown',
|
'source' => $data['source'] ?? 'unknown',
|
||||||
'type' => $data['type'] ?? 'error',
|
'type' => $data['type'] ?? 'error',
|
||||||
|
|||||||
@@ -11,8 +11,11 @@ class Log
|
|||||||
public function report(): Json
|
public function report(): Json
|
||||||
{
|
{
|
||||||
if (!Request::instance()->isPost()) return json(['status' => 0]);
|
if (!Request::instance()->isPost()) return json(['status' => 0]);
|
||||||
$raw = file_get_contents('php://input');
|
$data = Request::instance()->post();
|
||||||
$data = json_decode($raw, true) ?: 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', [
|
\app\utils\Logger::error(\app\utils\Logger::CAT_FRONTEND, $data['message'] ?? 'unknown', [
|
||||||
'source' => $data['source'] ?? 'unknown',
|
'source' => $data['source'] ?? 'unknown',
|
||||||
'type' => $data['type'] ?? 'error',
|
'type' => $data['type'] ?? 'error',
|
||||||
|
|||||||
Reference in New Issue
Block a user