在请求如 /_next/static/media/page-main-image.0b61c706.png 这样的文件时
这段配置可以正常运行
location ~* /_next/static/.*(js|css|png|jpg|jpeg|svg|gif|ico|ttf|webp)$ { rewrite /_next/(.*) /.next/$1 break; try_files $uri $uri/; expires 1y; # 设置缓存时间为 1 年 add_header Cache-Control "public"; } 这段配置却找不到文件、响应体还会变成 308 重定向
location ~* /_next/static/.*(js|css|png|jpg|jpeg|svg|gif|ico|ttf|webp)$ { alias /app/.next/static/; # 将请求路径 /_next/static/ 映射到文件系统的 /app/.next/static/ expires 1y; # 设置缓存时间为 1 年 add_header Cache-Control "public"; } 