Caddyfile for Django API and SPA

Me again! After pairing with a colleague, we found this answer which was helpful. I’ll let here the final configuration that works:

mydomain.com {
    log {
        output stdout
        level DEBUG
    }
    
    root /static/* /path/to/back
    root /media/* /path/to/back
    root * /path/to/front/dist
    
    route {
        reverse_proxy /admin* 127.0.0.1:8000
        reverse_proxy /api* 127.0.0.1:8000
        try_files {path} {path}/ /index.html
        file_server
    }
}