diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 71be6f0..b4d4f68 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -157,11 +157,22 @@ http { return end + -- 记录请求体大小,方便调试 + ngx.log(ngx.INFO, "Received body size: ", string.len(body)) + -- 解析 JSON local ok, data = pcall(cjson.decode, body) if not ok then + -- 记录解析错误的详细信息 + ngx.log(ngx.ERR, "JSON parse error: ", data) + ngx.log(ngx.ERR, "Body preview (first 500 chars): ", string.sub(body, 1, 500)) ngx.status = 400 - ngx.say(cjson.encode({error = "Invalid JSON"})) + ngx.say(cjson.encode({ + error = "Invalid JSON", + details = tostring(data), + body_size = string.len(body), + body_preview = string.sub(body, 1, 200) + })) return end