fix: raise request body limit to 1GB

This commit is contained in:
2026-07-01 16:26:59 +08:00
parent c8cc3b153b
commit 446a0e99a8
6 changed files with 38 additions and 17 deletions
+15 -2
View File
@@ -28,6 +28,8 @@ import {
} from "./admin-lib.mjs";
const DEFAULT_PROFILES_DIR = path.join(os.homedir(), ".config", "codex-retry-gateway", "profiles");
const DEFAULT_REQUEST_BODY_LIMIT_BYTES = 1024 * 1024 * 1024;
const LEGACY_DEFAULT_REQUEST_BODY_LIMIT_BYTES = 10 * 1024 * 1024;
function parseEnvFile(content) {
const parsed = {};
@@ -91,6 +93,17 @@ function boolFromEnv(value, fallback = false) {
return ["1", "true", "yes", "on"].includes(`${value}`.trim().toLowerCase());
}
function normalizeRequestBodyLimitBytes(value) {
const parsed = Number.parseInt(`${value ?? ""}`, 10);
if (!Number.isFinite(parsed) || parsed <= 0) {
return DEFAULT_REQUEST_BODY_LIMIT_BYTES;
}
if (parsed === LEGACY_DEFAULT_REQUEST_BODY_LIMIT_BYTES) {
return DEFAULT_REQUEST_BODY_LIMIT_BYTES;
}
return parsed;
}
function normalizeAuthMode(value) {
const mode = `${value || "passthrough"}`.trim().toLowerCase();
if (["passthrough", "fixed_bearer", "manual_bearer", "auth_json"].includes(mode)) {
@@ -180,8 +193,8 @@ function buildProfileConfig({ profileName, profileEnv, existingGatewayConfig, pr
upstream_base_url: upstreamBaseUrl,
...profileAuthConfig,
request_body_limit_bytes: profileEnv.CODEX_RETRY_GATEWAY_REQUEST_BODY_LIMIT_BYTES
? Number.parseInt(`${profileEnv.CODEX_RETRY_GATEWAY_REQUEST_BODY_LIMIT_BYTES}`, 10)
: Number.parseInt(`${existingGatewayConfig?.request_body_limit_bytes || 10485760}`, 10),
? normalizeRequestBodyLimitBytes(profileEnv.CODEX_RETRY_GATEWAY_REQUEST_BODY_LIMIT_BYTES)
: normalizeRequestBodyLimitBytes(existingGatewayConfig?.request_body_limit_bytes),
request_history_limit: profileEnv.CODEX_RETRY_GATEWAY_REQUEST_HISTORY_LIMIT
? Number.parseInt(`${profileEnv.CODEX_RETRY_GATEWAY_REQUEST_HISTORY_LIMIT}`, 10)
: Number.parseInt(`${existingGatewayConfig?.request_history_limit || 200}`, 10),