From f1a7ad8a2f0da28b973409636591344aea73e59a Mon Sep 17 00:00:00 2001 From: seaislee1209 Date: Sat, 4 Apr 2026 19:16:38 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20nginx=20/assets=20=E8=B7=AF=E7=94=B1=204?= =?UTF-8?q?03=20=E4=BF=AE=E5=A4=8D=20=E2=80=94=20=E9=9D=99=E6=80=81?= =?UTF-8?q?=E7=BC=93=E5=AD=98=E6=94=B9=E4=B8=BA=E6=AD=A3=E5=88=99=E5=8C=B9?= =?UTF-8?q?=E9=85=8D=E6=96=87=E4=BB=B6=E6=89=A9=E5=B1=95=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit /assets/ location 会拦截 SPA 路由 /assets(资产页),导致刷新 403。 改为正则匹配 /assets/*.{js,css,png,...},只缓存实际静态文件, 不影响 SPA fallback 到 index.html。 Co-Authored-By: Claude Opus 4.6 (1M context) --- web/nginx.conf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/web/nginx.conf b/web/nginx.conf index 4a68823..72f934b 100644 --- a/web/nginx.conf +++ b/web/nginx.conf @@ -24,8 +24,9 @@ server { client_max_body_size 50m; } - # Cache static assets (must be before SPA fallback) - location /assets/ { + # Cache static assets (JS/CSS/images built by Vite into dist/assets/) + # Use regex to only match actual files with extensions, not bare /assets path + location ~* ^/assets/.+\.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|mp4|webm)$ { expires 30d; add_header Cache-Control "public, immutable"; }