mirror of
https://github.com/dqzboy/Docker-Proxy.git
synced 2026-07-01 13:45:50 +08:00
27 lines
610 B
JavaScript
27 lines
610 B
JavaScript
/**
|
|
* 客户端错误处理中间件
|
|
*/
|
|
const logger = require('../logger');
|
|
|
|
// 处理客户端上报的错误
|
|
function handleClientError(req, res, next) {
|
|
if (req.url === '/api/client-error' && req.method === 'POST') {
|
|
const { message, source, lineno, colno, error, stack, userAgent, page } = req.body;
|
|
|
|
logger.error('客户端错误:', {
|
|
message,
|
|
source,
|
|
location: `${lineno}:${colno}`,
|
|
stack: stack || (error && error.stack),
|
|
userAgent,
|
|
page
|
|
});
|
|
|
|
res.json({ success: true });
|
|
} else {
|
|
next();
|
|
}
|
|
}
|
|
|
|
module.exports = handleClientError;
|