:{$PORT:5000} {
    root * /usr/share/caddy

    # Recipe images are stored in a shared volume and served by the Next service.
    handle /images/* {
        reverse_proxy recipe-frontend:3000
    }

    # Proxy API calls to backend service on the internal Docker network.
    handle /api/* {
        reverse_proxy recipe-api:8080
    }

    # SPA-routing – returnera alltid index.html för okända paths
    handle {
        try_files {path} /index.html
        file_server
    }

    encode gzip
}
