Update storage.js via upload script - 2026-08-24 09:30:38

This commit is contained in:
mike 2026-08-24 09:30:49 +08:00
parent c02aff38b3
commit b5934aae02
1 changed files with 12 additions and 1 deletions

View File

@ -38,7 +38,18 @@ export async function uploadFile(customerId, file) {
body: fd, body: fd,
}); });
if (!res.ok) { if (!res.ok) {
throw new Error(`upload failed: ${res.status}`); let msg = `上传失败HTTP ${res.status}`;
try {
const data = await res.json();
if (data && data.error) msg = data.error;
} catch (e) {
// 响应不是JSON——说明请求可能根本没到Node这一层就被拦下了最常见的原因是
// Nginx反向代理的client_max_body_size默认1MB比文件小直接返回了413的HTML错误页
if (res.status === 413) {
msg = '文件太大被Nginx反向代理拦截了默认限制1MB。需要去Nginx配置里把client_max_body_size调大改完执行 nginx -t 和 systemctl reload nginx';
}
}
throw new Error(msg);
} }
return res.json(); return res.json();
} }