# Nginx: serve Laravel public storage with symlink fallback
#
# When public/storage symlink exists, Nginx serves files directly.
# When it does not (common on cPanel), requests fall through to Laravel.

location /storage {
    alias /path/to/your/project/storage/app/public;
    try_files $uri $uri/ @storage_fallback;
    access_log off;
    expires 1y;
    add_header Cache-Control "public, immutable";
}

location @storage_fallback {
    rewrite ^/storage/(.*)$ /index.php?path=$1 last;
}

# If using the Laravel route fallback only (no alias), use:
# location /storage {
#     try_files $uri $uri/ /index.php?$query_string;
# }
