liuw15 commited on
Commit
6557788
·
1 Parent(s): 2711b18

修复请求日志显示

Browse files
Files changed (1) hide show
  1. src/server/index.js +4 -2
src/server/index.js CHANGED
@@ -54,10 +54,12 @@ app.use((req, res, next) => {
54
  '/sdapi/v1/upscalers', '/sdapi/v1/latent-upscale-modes',
55
  '/sdapi/v1/sd-vae', '/sdapi/v1/sd-modules'
56
  ];
57
- if (!ignorePaths.some(p => req.path.startsWith(p))) {
 
 
58
  const start = Date.now();
59
  res.on('finish', () => {
60
- logger.request(req.method, req.path, res.statusCode, Date.now() - start);
61
  });
62
  }
63
  next();
 
54
  '/sdapi/v1/upscalers', '/sdapi/v1/latent-upscale-modes',
55
  '/sdapi/v1/sd-vae', '/sdapi/v1/sd-modules'
56
  ];
57
+ // 提前获取完整路径,避免在路由处理后 req.path 被修改为相对路径
58
+ const fullPath = req.originalUrl.split('?')[0];
59
+ if (!ignorePaths.some(p => fullPath.startsWith(p))) {
60
  const start = Date.now();
61
  res.on('finish', () => {
62
+ logger.request(req.method, fullPath, res.statusCode, Date.now() - start);
63
  });
64
  }
65
  next();