From 817e2621400438f1d9c6c0b13e51c8f22aac40ca Mon Sep 17 00:00:00 2001 From: testadmin Date: Thu, 14 May 2026 11:37:58 +0800 Subject: [PATCH] fix: frontend error reporting route - bypass auth middleware MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- app/handle/controller/Log.php | 28 +++++++++++++++++++++++++ public/static/handle/js/error-report.js | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 app/handle/controller/Log.php diff --git a/app/handle/controller/Log.php b/app/handle/controller/Log.php new file mode 100644 index 0000000..7f3622a --- /dev/null +++ b/app/handle/controller/Log.php @@ -0,0 +1,28 @@ +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]); + } +} diff --git a/public/static/handle/js/error-report.js b/public/static/handle/js/error-report.js index 2a5b519..0a3998b 100644 --- a/public/static/handle/js/error-report.js +++ b/public/static/handle/js/error-report.js @@ -1,5 +1,5 @@ (function() { - var reportUrl = '/index/log_report'; + var reportUrl = '/log/report'; var queue = []; var sending = false;