I am running an express node app with objection.js which uses knex on Heroku. Whenever I make a request to an endpoint that makes a database connection, I get the following error.
What does the error invalid_authorization_specification (code 28000) even mean?
Any advice here would be appreciated
{
"name": "DBError",
"nativeError": {
"length": 164,
"name": "error",
"severity": "FATAL",
"code": "28000",
"file": "auth.c",
"line": "496",
"routine": "ClientAuthentication"
},
"client": "postgres"
}
My knexfile contains the following. I've tried using connection: process.env.DATABASE_URL
as well, still no dice.
const db_url = process.env.DATABASE_URL
var db_url_groups = db_url.match(/^.*\/\/(.*):(.*)@(.*):.*\/(.*)$/)
var dbUser = db_url_groups[1]
var dbPw = db_url_groups[2]
var dbHost = db_url_groups[3]
var db = db_url_groups[4]
module.exports = {
development: {
client: 'pg',
useNullAsDefault: true,
connection: {
host : 'db',
user : 'test',
password : 'test',
database : 'local_db'
}
},
production: {
client: 'pg',
useNullAsDefault: true,
connection: {
host : `${dbHost}`,
user : `${dbUser}`,
password : `${dbPw}`,
database : `${db}`
}
}
}
The issue had something to do with SSL. Within the connection property, I needed to add an ssl property with the following:
ssl: { require: false, rejectUnauthorized: false }