From 3e5f43ebeda7e37de623aba89fe7076cf638a104 Mon Sep 17 00:00:00 2001 From: nilsorbat Date: Fri, 24 Feb 2023 20:22:07 +0100 Subject: [PATCH 1/2] provide a fix and documentation for postgres connections, that require ssl mode --- docker-compose.yml | 5 +++++ server/.env.sample | 5 +++++ server/db/knexfile.js | 7 ++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index bbe31759..d85980d7 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -23,6 +23,11 @@ services: - TRUST_PROXY=0 - DATABASE_URL=postgresql://postgres@postgres/planka - SECRET_KEY=notsecretkey + # related: https://github.com/knex/knex/issues/2354 + # As knex does not pass query parameters from the connection string we + # have to use environment variables in order to pass the desirec values, e.g. + # note: this is optional + # PGSSLMODE=require depends_on: - postgres diff --git a/server/.env.sample b/server/.env.sample index b9b6f2e9..84c57f0f 100644 --- a/server/.env.sample +++ b/server/.env.sample @@ -9,6 +9,11 @@ SECRET_KEY=notsecretkey # TRUST_PROXY=0 # TOKEN_EXPIRES_IN=365 # In days +# related: https://github.com/knex/knex/issues/2354 +# As knex does not pass query parameters from the connection string we +# have to use environment variables in order to pass the desirec values, e.g. +# PGSSLMODE= + ## Do not edit this TZ=UTC diff --git a/server/db/knexfile.js b/server/db/knexfile.js index ef294733..7ba13d94 100755 --- a/server/db/knexfile.js +++ b/server/db/knexfile.js @@ -8,7 +8,12 @@ dotenv.config({ module.exports = { client: 'pg', - connection: process.env.DATABASE_URL, + connection: { + connectionString: process.env.DATABASE_URL, + ssl: { + rejectUnauthorized: false, + }, + }, migrations: { tableName: 'migration', directory: path.join(__dirname, 'migrations'), From 6188a716ccadc9a7ae8ca431edd08057aadf0f7c Mon Sep 17 00:00:00 2001 From: nilsorbat Date: Fri, 24 Feb 2023 20:38:11 +0100 Subject: [PATCH 2/2] fix spelling mistake --- docker-compose.yml | 2 +- server/.env.sample | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index d85980d7..c09bb9e1 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -25,7 +25,7 @@ services: - SECRET_KEY=notsecretkey # related: https://github.com/knex/knex/issues/2354 # As knex does not pass query parameters from the connection string we - # have to use environment variables in order to pass the desirec values, e.g. + # have to use environment variables in order to pass the desired values, e.g. # note: this is optional # PGSSLMODE=require depends_on: diff --git a/server/.env.sample b/server/.env.sample index 84c57f0f..aac41a0d 100644 --- a/server/.env.sample +++ b/server/.env.sample @@ -11,7 +11,7 @@ SECRET_KEY=notsecretkey # related: https://github.com/knex/knex/issues/2354 # As knex does not pass query parameters from the connection string we -# have to use environment variables in order to pass the desirec values, e.g. +# have to use environment variables in order to pass the desired values, e.g. # PGSSLMODE= ## Do not edit this