From c885051ab3f40a6203ba90cfe702ebbe42e82c62 Mon Sep 17 00:00:00 2001 From: zyc <1439655764@qq.com> Date: Sat, 4 Apr 2026 12:58:28 +0800 Subject: [PATCH] fix: nginx config serving assets as text/html instead of correct MIME type --- web/nginx.conf | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/web/nginx.conf b/web/nginx.conf index a3a2203..4a68823 100644 --- a/web/nginx.conf +++ b/web/nginx.conf @@ -24,19 +24,14 @@ server { client_max_body_size 50m; } - # SPA client-side routes — must return index.html, not match Vite's dist/assets/ dir - location ~ ^/(assets|login|profile|admin|team)(/|$) { - try_files /index.html =404; - } - - # SPA fallback - location / { - try_files $uri $uri/ /index.html; - } - - # Cache static assets - location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { + # Cache static assets (must be before SPA fallback) + location /assets/ { expires 30d; add_header Cache-Control "public, immutable"; } + + # SPA fallback — real files served directly, all other paths return index.html + location / { + try_files $uri $uri/ /index.html; + } }