401 Disconnect Error When Connecting from one Flyio Backend to Another Flyio Frontend

I’m deploying two apps from Flyio - a frontend and backend.

  • I can access the backend through the browser,
  • The frontend can access https://google.com through a Python requests GET request,
  • The frontend cannot access the backend through a Python requests GET request.

The frontend is making a GET request to https://dss-backend.fly.dev/whoami/ and failing - I can access this url through a browser though…

Where is my problem? Here are the two config TOML for each app:

#  backend.toml
# fly.toml file generated for dss-backend on 2022-12-18T23:27:21+13:00

app = "dss-backend"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[build]
  dockerfile = "../docker/backend.Dockerfile"

[build.args]
  BACKEND_PORT = 8080
  BACKEND_URL = "0.0.0.0"
  ENVFILE = "no-env-file"

[env]
  BACKEND_PORT = 8080
  BACKEND_URL = "0.0.0.0"
  ENVFILE = "no-env-file"

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []

  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 8080

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443
    tls_options = { "alpn" = ["h2", "http/1.1"], "versions" = ["TLSv1.2", "TLSv1.3"], }

  [[services.tcp_checks]]
    grace_period = "3s"
    interval = "15s"
    restart_limit = 0
    timeout = "1s"
#  frontend.toml
# fly.toml file generated for dss-frontend on 2022-12-18T23:59:06+13:00

app = "dss-frontend"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[build]
  dockerfile = "../docker/frontend.Dockerfile"

[build.args]
  FRONTEND_PORT = 8080
  BACKEND_PORT = -1
  BACKEND_URL = "dss-backend.fly.dev"
  ENVFILE = "no-env-file"

[env]
  FRONTEND_PORT = 8080
  BACKEND_PORT = -1
  BACKEND_URL = "dss-backend.fly.dev"
  ENVFILE = "no-env-file"

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []

  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    force_https = true
    handlers = ["http"]
    port = 8080

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443
    tls_options = { "alpn" = ["h2", "http/1.1"], "versions" = ["TLSv1.2", "TLSv1.3"], }

  [[services.tcp_checks]]
    grace_period = "3s"
    interval = "15s"
    restart_limit = 0
    timeout = "10s"

The problem was doing requests to https://host/endpoint/ rather than https://host/endpoint - silly mistake!