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:
@@ -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,5 +1,5 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var reportUrl = '/index/log_report';
|
var reportUrl = '/log/report';
|
||||||
var queue = [];
|
var queue = [];
|
||||||
var sending = false;
|
var sending = false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user