fix: nginx /assets 路由 403 修复 — 静态缓存改为正则匹配文件扩展名
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 4m32s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 4m32s
/assets/ location 会拦截 SPA 路由 /assets(资产页),导致刷新 403。
改为正则匹配 /assets/*.{js,css,png,...},只缓存实际静态文件,
不影响 SPA fallback 到 index.html。
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
9a6d95a69d
commit
f1a7ad8a2f
@ -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";
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user