Reputation: 61
I'm using free tier of heroku to deploy an app. I've managed to create the app with the build being successful on heroku. I pushed to heroku and tried heroku local
and the app runs as it should. However if I try heroku open
the browser opens to the heroku "Application error" page.
I tried running NODE_ENV=production heroku local
as a troubleshooting step and that does cause the app to break. I get
Error: self signed certificate
at TLSSocket.onConnectSecure (_tls_wrap.js:1492:34)
at TLSSocket.emit (evens.js:315:20)
at TLSSocket._finishInit (_tls_wrap.js:935:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:693:12)
The github repo is here: https://github.com/JoeCastr/budget_app
My package.json:
{
"name": "budget_app_project",
"version": "1.0.0",
"description": "",
"main": "budget.js",
"scripts": {
"start": "npx nodemon budget.js",
"heroku-postbuild": "npm install --production",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"eslint": "^6.8.0",
"eslint-config-airbnb-base": "^14.1.0",
"eslint-plugin-import": "^2.20.2",
"nodemon": "^2.0.3"
},
"dependencies": {
"bcrypt": "^4.0.1",
"connect-loki": "^1.1.0",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"express-flash": "0.0.2",
"express-session": "^1.17.1",
"express-validator": "^6.5.0",
"morgan": "^1.10.0",
"pg": "^8.2.1",
"pug": "^2.0.4"
},
"engines": {
"node": "13.12.0",
"npm": "6.14.4"
}
}
Upvotes: 2
Views: 1538
Reputation: 11
After so much struggle this works for me:
const pool = new Pool({
connectionString: process.env.yourDatabaseURL,
ssl: { rejectUnauthorized: false }
})
Upvotes: 1
Reputation: 61
The problem is with pg version 8.x it breaks heroku. the connection constant needs to be:
const CONNECTION = {
connectionString: process.env.DATABASE_URL,
ssl: {
rejectUnauthorized: false
}
}
Upvotes: 4