Fix nginx try_files to prefer .html over directories

This commit is contained in:
Jeff Emmett 2025-11-27 20:34:10 -08:00
parent 501ef48e53
commit e1ac6e4c33
1 changed files with 3 additions and 2 deletions

View File

@ -18,8 +18,9 @@ server {
# Handle Next.js static export routes
location / {
# Try exact file, then .html extension, then directory, then fallback to index.html
try_files $uri $uri.html $uri/ /index.html;
# Try exact file, then .html extension, then directory index, then fallback
# Note: $uri.html must come before $uri/ to handle directories without index.html
try_files $uri $uri.html $uri/index.html /index.html;
}
# Cache static assets