fix(middleware): skip logging for blocked connections to specific paths

42f850239fa59e627ee420d4bd6a09cadc18ebcb

KevinSun <paver.mails+github@gmail.com>

Signed
1 files changed, +8 -0Showing whitespace changes
src/middleware/whitelist.js+8 -0
@@ -55,6 +55,10 @@ export default function whitelistMiddleware(whitelistMode) {
5555 safeReadFileSync('./public/error/forbidden-by-whitelist.html') ?? '',
5656 );
5757
58+ const noLogPaths = [
59+ '/favicon.ico',
60+ ];
61+
5862 return function (req, res, next) {
5963 const clientIp = getIpFromRequest(req);
6064 const forwardedIp = getForwardedIp(req);
@@ -68,11 +72,15 @@ export default function whitelistMiddleware(whitelistMode) {
6872 const ipDetails = forwardedIp
6973 ? `${clientIp} (forwarded from ${forwardedIp})`
7074 : clientIp;
75+
76+ if (!noLogPaths.includes(req.path)) {
7177 console.warn(
7278 color.red(
7379 `Blocked connection from ${clientIp}; User Agent: ${userAgent}\n\tTo allow this connection, add its IP address to the whitelist or disable whitelist mode by editing config.yaml in the root directory of your SillyTavern installation.\n`,
7480 ),
7581 );
82+ }
83+
7684 return res.status(403).send(forbiddenWebpage({ ipDetails }));
7785 }
7886 next();