server {
  listen 80;
server_name sirh.malio-dev.fr;

  root /var/www/sirh/frontend/.output/public;
  index index.html;

    location ^~ /api/ {
        root /var/www/sirh/public;
        try_files $uri /index.php?$query_string;
    }

    location ^~ /bundles/ {
        root /var/www/sirh/public;
        try_files $uri =404;
    }

    location = /api/login_check {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME /var/www/sirh/public/index.php;
        fastcgi_param DOCUMENT_ROOT /var/www/sirh/public;
        fastcgi_param SCRIPT_NAME /index.php;
        fastcgi_param PATH_INFO /login_check;
        fastcgi_param REQUEST_URI /login_check;
        fastcgi_pass unix:/run/php/php8.4-fpm.sock;
    }

    location ~ ^/index\.php(/|$) {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME /var/www/sirh/public/index.php;
        fastcgi_param DOCUMENT_ROOT /var/www/sirh/public;
        fastcgi_pass unix:/run/php/php8.4-fpm.sock;
        internal;
    }

  location ~ \.php$ {
      return 404;
  }

  location / {
      try_files $uri $uri/ /index.html;
  }
}
