mirror of
https://github.com/jina-ai/node-DeepResearch.git
synced 2026-03-22 07:29:35 +08:00
add more info for validation errors
This commit is contained in:
13
src/app.ts
13
src/app.ts
@@ -384,10 +384,16 @@ const validationRules = [
|
||||
];
|
||||
|
||||
app.post('/v1/chat/completions', validationRules, (async (req: Request, res: Response) => {
|
||||
const clientIp = req.headers['cf-connecting-ip'] ||
|
||||
req.headers['x-forwarded-for'] ||
|
||||
req.ip ||
|
||||
req.socket.remoteAddress ||
|
||||
'unknown';
|
||||
|
||||
// Validate request body
|
||||
const errors = validationResult(req);
|
||||
if (!errors.isEmpty()) {
|
||||
logError('[chat/completions] Validation errors:', { errors: errors.array() });
|
||||
logError('[chat/completions] Validation errors:', { errors: errors.array(), ip: clientIp });
|
||||
return res.status(400).json({ error: 'Invalid request body', details: errors.array() });
|
||||
}
|
||||
|
||||
@@ -401,11 +407,6 @@ app.post('/v1/chat/completions', validationRules, (async (req: Request, res: Res
|
||||
}
|
||||
}
|
||||
|
||||
const clientIp = req.headers['cf-connecting-ip'] ||
|
||||
req.headers['x-forwarded-for'] ||
|
||||
req.ip ||
|
||||
req.socket.remoteAddress ||
|
||||
'unknown';
|
||||
// Log request details (excluding sensitive data)
|
||||
logInfo('[chat/completions] Request:', {
|
||||
model: req.body.model,
|
||||
|
||||
Reference in New Issue
Block a user