fix(deploy): disable gzip on /v1/ API paths — Flutter release AOT gzip decompression failure

服务端 200+数据正常、debug/JIT 正常;release/AOT 的 Dart HttpClient 对
Content-Encoding: gzip 解压异常 → JSON 解析失败 → 显示 INTERNAL_ERROR。
nginx /v1/ 路径 gzip off(静态资源 gzip 不受影响);proguard keep 规则
一并保留(dio/flutter_secure_storage/全项目模型)。

Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
浅念
2026-09-23 18:36:11 +08:00
parent fa06193a12
commit 222c44c1f7
9 changed files with 203 additions and 6 deletions
+18 -3
View File
@@ -36,9 +36,24 @@ server {
gzip_min_length 1024;
gzip_types text/css application/javascript application/json image/svg+xml;
# /v1 → API 容器(viewer/admin 前端均为同源相对路径请求)。
location /v1/ {
proxy_pass ${API_UPSTREAM};
# API 路径禁用 gzip(2026-09-23:Flutter release AOT 的 HTTP 客户端
# 对 gzip 响应解压异常——debug/JIT 正常,release/AOT 全挂 INTERNAL_ERROR;
# 静态资源 gzip 不受影响)。
location ^~ /v1/ {
gzip off;
proxy_pass http://${API_UPSTREAM};
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
}
;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;