mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-19 09:50:15 +01:00
20 lines
467 B
JavaScript
20 lines
467 B
JavaScript
const { handleError } = require('../utils');
|
|||
|
|||
function validateEndpoint(req, res, next) {
|
|||
const { endpoint } = req.body;
|
|||
|
|||
if (!req.body.text || req.body.text.length === 0) {
|
|||
return handleError(res, { text: 'Prompt empty or too short' });
|
|||
}
|
|||
|
|||
const pathEndpoint = req.baseUrl.split('/')[3];
|
|||
|
|||
if (endpoint !== pathEndpoint) {
|
|||
return handleError(res, { text: 'Illegal request: Endpoint mismatch' });
|
|||
}
|
|||
|
|||
next();
|
|||
}
|
|||
|
|||
module.exports = validateEndpoint;
|