root $dir_path;

# The MeowIndex web app block
location /__meowindex__ {
    alias /etc/nginx/MeowIndex/dist;

    # Use sub_filter to configure the app
    sub_filter_types application/javascript;
    sub_filter_once off;
    sub_filter "{DEPLOY-PATH-PLACEHOLDER}" "/__meowindex__";
    sub_filter "{HOST-PLACEHOLDER}" "/api";
    sub_filter "\"/assets" "\"/__meowindex__/assets";
    sub_filter "File Listing" $title;

    # Serve index.html on other 404 paths as well
    try_files $uri /__meowindex__/index.html;
}

# The api block
location /api {
    alias $dir_path;
    index DISABLE_INDEX_HTML_AUTO_MATCHING;

    autoindex on;
    autoindex_format json;
    add_header Access-Control-Allow-Origin *;
}
