Merge pull request #799 from kikii16/main [skip ci]

尝试自定义请求体maxSize大小
This commit is contained in:
Wesley Liddick
2025-12-12 01:58:12 -05:00
committed by GitHub
3 changed files with 8 additions and 1 deletions

View File

@@ -61,6 +61,9 @@ PROXY_USE_IPV4=true
# ⏱️ 请求超时配置 # ⏱️ 请求超时配置
REQUEST_TIMEOUT=600000 # 请求超时设置毫秒默认10分钟 REQUEST_TIMEOUT=600000 # 请求超时设置毫秒默认10分钟
# 🔧 请求体大小配置
REQUEST_MAX_SIZE_MB=60
# 📈 使用限制 # 📈 使用限制
DEFAULT_TOKEN_LIMIT=1000000 DEFAULT_TOKEN_LIMIT=1000000

View File

@@ -21,6 +21,9 @@ services:
- PORT=3000 - PORT=3000
- HOST=0.0.0.0 - HOST=0.0.0.0
# 🔧 请求体大小配置
- REQUEST_MAX_SIZE_MB=60
# 🔐 安全配置(必填) # 🔐 安全配置(必填)
- JWT_SECRET=${JWT_SECRET} # 必填至少32字符的随机字符串 - JWT_SECRET=${JWT_SECRET} # 必填至少32字符的随机字符串
- ENCRYPTION_KEY=${ENCRYPTION_KEY} # 必填32字符的加密密钥 - ENCRYPTION_KEY=${ENCRYPTION_KEY} # 必填32字符的加密密钥

View File

@@ -1388,7 +1388,8 @@ const globalRateLimit = async (req, res, next) =>
// 📊 请求大小限制中间件 // 📊 请求大小限制中间件
const requestSizeLimit = (req, res, next) => { const requestSizeLimit = (req, res, next) => {
const maxSize = 60 * 1024 * 1024 // 60MB const MAX_SIZE_MB = parseInt(process.env.REQUEST_MAX_SIZE_MB || '60', 10)
const maxSize = MAX_SIZE_MB * 1024 * 1024
const contentLength = parseInt(req.headers['content-length'] || '0') const contentLength = parseInt(req.headers['content-length'] || '0')
if (contentLength > maxSize) { if (contentLength > maxSize) {