server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name localhost;
    
    # Point directly to the 'public' folder of Laravel
    root "D:/Lab/HomeLab/Github/dyzulk/nihonbuzz-academy/public";
    
    index index.html index.htm index.php;
 
    # Log files for debugging
    access_log "C:/laragon/tmp/nginx.access.log";
    error_log  "C:/laragon/tmp/nginx.error.log";

    charset utf-8;

    # Optimal configuration for Laravel / Single Page Apps (SPA)
    location / {
        try_files $uri $uri/ /index.php?$query_string;
        autoindex off;
    }
    
    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }
    
    # PHP Processing
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        
        # Ensure this matches your Laragon PHP version (adjust if needed)
        fastcgi_pass php_upstream;
        # fastcgi_pass unix:/run/php/php8.2-fpm.sock; 
    }

    # Deny access to hidden files (.env, .git, etc.)
    location ~ /\.(?!well-known).* {
        deny all;
    }

    include "C:/laragon/etc/nginx/alias/*.conf";
}
