0

I've managed deploying my Strapi app on Fly.io, connected to a PostgreSQL database on Supabase.

I've followed this Strapi guide, but it seems a little bit outdated so I made some custom edits on my setup.

It... sometimes work, but I regulary get 502 bad gateway errors (after one minute).

It feels like the app was idle. After a while, I start to get responses (a few seconds) and it works. A few hours later, it does not response again.

About my setup

The default port in Strapi is 1337.

But Fly.io now charges 2$/mo to use custom ports. Since I'm a hobby user, I then need to use the "free" ports, which are 80 and 443.

database.js

module.exports = ({ env }) => ({
  connection: {
    client: 'postgres',
    connection: {
      host: env('DATABASE_HOST','localhost'),
      port: env.int('DATABASE_PORT', 5432),
      database: env('DATABASE_NAME'),
      user: env('DATABASE_USERNAME','postgres'),
      password: env('DATABASE_PASSWORD'),
      schema: env('DATABASE_SCHEMA', 'public'), // Not required
      ssl: {
        rejectUnauthorized: env.bool('DATABASE_SSL_SELF', false),
      },
    },
    debug: false,
  },
});

also tested with

  ssl: false

fly.toml

[[services]]
  http_checks = []
  internal_port = 80
  processes = ["app"]
  protocol = "tcp"
  script_checks = []
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

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

[[services.ports]]
  handlers = ["tls", "http"]
  port = 443

[[services.tcp_checks]]
  grace_period = "1s"
  interval = "15s"
  restart_limit = 0
  timeout = "2s"

[env]
  PORT="80"

dockerfile

# Expose the Strapi port
EXPOSE 80

It seems that some other users have this problem on Fly.io + Supabase. Someone says here

that would mean the connection gets closed before response headers are fully sent back from your app.

Can anyone help ? Thanks !

gordie
  • 1,637
  • 3
  • 21
  • 41

0 Answers0