:8002 {
    log {
        output stdout
        format filter {
            wrap json
            fields {
                common_log delete
                request>headers delete
                resp_headers delete
                tls delete
            }
        }
    }

    {{ patch("mfe-caddyfile") | indent(4) }}

    reverse_proxy /api/mfe_config/v1* lms:8000 {
        # We need to specify the host header, otherwise it will be rejected with 400
        # from the lms.
        header_up Host {{ LMS_HOST }}
    }

    {% for app_name, app in iter_mfes() %}
    @mfe_{{ app_name }} {
        path /{{ app_name }} /{{ app_name }}/*
    }
    handle @mfe_{{ app_name }} {
        uri strip_prefix /{{ app_name }}
        root * /openedx/dist/{{ app_name }}
        try_files /{path} /index.html
        file_server
    }
    {% endfor %}
}
