CatPtain commited on
Commit
3c16823
·
verified ·
1 Parent(s): c4c2366

Upload app.js

Browse files
Files changed (1) hide show
  1. backend/src/app.js +5 -2
backend/src/app.js CHANGED
@@ -39,12 +39,15 @@ app.use(helmet({
39
  contentSecurityPolicy: false, // 为了兼容前端静态文件
40
  }));
41
 
42
- // 修复限流配置 - 针对Huggingface Space环境
43
  const limiter = rateLimit({
44
  windowMs: 15 * 60 * 1000, // 15分钟
45
  max: 100, // 每个IP每15分钟最多100个请求
46
  message: 'Too many requests from this IP, please try again later.',
47
- trustProxy: false, // 在本地测试环境设为false
 
 
 
48
  standardHeaders: true,
49
  legacyHeaders: false
50
  });
 
39
  contentSecurityPolicy: false, // 为了兼容前端静态文件
40
  }));
41
 
42
+ // 修复限流配置 - 针对Huggingface Space生产环境
43
  const limiter = rateLimit({
44
  windowMs: 15 * 60 * 1000, // 15分钟
45
  max: 100, // 每个IP每15分钟最多100个请求
46
  message: 'Too many requests from this IP, please try again later.',
47
+ trustProxy: true, // 与Express trust proxy设置保持一致
48
+ validate: {
49
+ trustProxy: false // 禁用trust proxy验证以避免生产环境警告
50
+ },
51
  standardHeaders: true,
52
  legacyHeaders: false
53
  });