From 8c897739a6f7c18c57152fe0ba6a3e7372febbd8 Mon Sep 17 00:00:00 2001 From: zzh <1368735060@qq.com> Date: Tue, 8 Sep 2026 18:22:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BE=AE=E4=BF=A1=20JS=20=E5=AE=89?= =?UTF-8?q?=E5=85=A8=E5=9F=9F=E5=90=8D=E6=A0=A1=E9=AA=8C=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=A4=9A=E4=BD=99=E6=8D=A2=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 确保 MP_verify 与公众平台下载包字节一致,并禁止 SPA 回落与 Git CRLF 改写。 Co-authored-by: Cursor --- .gitattributes | 2 ++ nginx-default.conf | 8 ++++++++ nginx-k3s.conf | 8 ++++++++ public/MP_verify_t0yrk6yNYOjmAe8m.txt | Bin 17 -> 16 bytes 4 files changed, 18 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..f246c7b --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# 微信域名校验文件必须与公众平台下载包字节完全一致(禁止 CRLF / 尾换行) +public/MP_verify_*.txt binary diff --git a/nginx-default.conf b/nginx-default.conf index 7814ccf..4e7e55a 100644 --- a/nginx-default.conf +++ b/nginx-default.conf @@ -420,6 +420,14 @@ server { add_header Expires "0"; } + # 微信 JS 安全域名校验:原样返回 txt,禁止 SPA 回落 index.html + location ~* ^/MP_verify_[A-Za-z0-9]+\.txt$ { + default_type text/plain; + charset off; + add_header Cache-Control "no-store"; + try_files $uri =404; + } + # ============ 静态资源缓存 ============ location ~* \.(?:js|css)$ { diff --git a/nginx-k3s.conf b/nginx-k3s.conf index 9ef5d41..6646a5d 100644 --- a/nginx-k3s.conf +++ b/nginx-k3s.conf @@ -160,6 +160,14 @@ server { add_header Expires "0"; } + # 微信 JS 安全域名校验:原样返回 txt,禁止 SPA 回落 index.html + location ~* ^/MP_verify_[A-Za-z0-9]+\.txt$ { + default_type text/plain; + charset off; + add_header Cache-Control "no-store"; + try_files $uri =404; + } + location ~* \.(?:js|css)$ { try_files $uri =404; expires 1y; diff --git a/public/MP_verify_t0yrk6yNYOjmAe8m.txt b/public/MP_verify_t0yrk6yNYOjmAe8m.txt index a4fdebd1e10f579d4c96d13e7d6ae2b689702c4f..8df6b4195d11877a99ae9df2c3c6df7dbb09ae58 100644 GIT binary patch literal 16 XcmXRhs4U7htMrTX&&qX7wa5hkG4ut( literal 17 YcmXRhs4U7htMrTX&&qX7waDcH05`w|%m4rY