fix: frontend error reporting route - bypass auth middleware

- Create handle/controller/Log.php (no auth) for dealer error reports
- Update error-report.js URL: /index/log_report → /log/report
- index app already has Log controller at /log/report
This commit is contained in:
testadmin
2026-05-14 11:37:58 +08:00
parent 3766975897
commit 817e262140
2 changed files with 29 additions and 1 deletions
+28
View File
@@ -0,0 +1,28 @@
<?php
declare (strict_types = 1);
namespace app\handle\controller;
use think\facade\Request;
use think\response\Json;
class Log
{
public function report(): Json
{
if (!Request::instance()->isPost()) return json(['status' => 0]);
$data = Request::instance()->post();
\app\utils\Logger::error(\app\utils\Logger::CAT_FRONTEND, $data['message'] ?? 'unknown', [
'source' => $data['source'] ?? 'unknown',
'type' => $data['type'] ?? 'error',
'stack' => isset($data['stack']) ? substr($data['stack'], 0, 2000) : '',
'file' => $data['file'] ?? '',
'url' => $data['url'] ?? '',
'line' => $data['line'] ?? '',
'col' => $data['col'] ?? '',
'ua' => Request::instance()->header('user-agent', ''),
'ip' => Request::instance()->ip(),
]);
return json(['status' => 1]);
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
(function() {
var reportUrl = '/index/log_report';
var reportUrl = '/log/report';
var queue = [];
var sending = false;