{
  auto_https off
  http_port 80
  https_port 0
}

(ai_pod_proxy) {
  reverse_proxy https://gpt-sovits-ai.{$LAZYCAT_BOX_DOMAIN} {
    header_up Host gpt-sovits-ai.{$LAZYCAT_BOX_DOMAIN}
    header_up X-Forwarded-Host {http.request.host}
    header_up X-Forwarded-Proto https
    header_up X-Forwarded-Uri {uri}
    transport http {
      tls_insecure_skip_verify
    }
  }
}

:80 {
  handle {
    route {
      handle /go/demo {
        redir * /demo/ 302
      }

      handle /go/full {
        redir * /full/ 302
      }

      handle /go/infer {
        redir * /infer/ 302
      }

      handle /go/uvr5 {
        redir * /uvr5/ 302
      }

      handle /go/label {
        redir * /label/ 302
      }

      handle /go/api {
        redir * /docs 302
      }

      handle /go/files {
        redir * /files 302
      }

      handle /demo {
        redir * /demo/ 308
      }

      handle /full {
        redir * /full/ 308
      }

      handle /infer {
        redir * /infer/ 308
      }

      handle /uvr5 {
        redir * /uvr5/ 308
      }

      handle /label {
        redir * /label/ 308
      }

      @ai_pod path /demo/* /full/* /infer/* /uvr5/* /label/* /files* /api/* /health /diagnostics* /tts* /set_gpt_weights* /set_sovits_weights* /docs* /openapi.json
      handle @ai_pod {
        import ai_pod_proxy
      }

      handle {
        root * /lzcapp/pkg/content/ui
        try_files {path} /index.html
        header Cache-Control "max-age=60, private, must-revalidate"
        file_server
      }
    }
  }
}
