server {
    listen 80;
    server_name localhost;
    root /usr/share/nginx/html;
    index index.html;

    # Required headers for SharedArrayBuffer (needed by Godot threads)
    add_header Cross-Origin-Opener-Policy "same-origin" always;
    add_header Cross-Origin-Embedder-Policy "require-corp" always;

    # Gzip compression
    gzip on;
    gzip_types application/javascript application/wasm text/html;

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

    location ~ \.wasm$ {
        add_header Content-Type application/wasm;
        add_header Cross-Origin-Opener-Policy "same-origin" always;
        add_header Cross-Origin-Embedder-Policy "require-corp" always;
    }

    location ~ \.pck$ {
        add_header Content-Type application/octet-stream;
        add_header Cross-Origin-Opener-Policy "same-origin" always;
        add_header Cross-Origin-Embedder-Policy "require-corp" always;
    }
}