0

Has anyone tried deploying postgres and node app with fly.io using knex?

I am trying to figure out what the connection string would be: knex({ client: "pg", connection: { host: process.env.DATABASE_URL, }, });

What would be the connection string be?

Prathmesh
  • 11
  • 4

1 Answers1

0

When you're using knex with a Postgres database, the DATABASE_URL environment variable is typically a connection string that includes the username, password, host, port, and database name.

postgres://username:password@localhost:5432/mydatabase

In the knex configuration, you can simply provide this DATABASE_URL as the connection. Knex can parse connection strings directly:

knex({
  client: 'pg',
  connection: process.env.DATABASE_URL,
});

In the context of fly.io, you'd generally obtain your DATABASE_URL as an environment variable set within your Fly.io application configuration.

Humza Tareen
  • 146
  • 6