mirror of
https://github.com/sergeyyarkov/node-docker-example.git
synced 2026-10-11 02:09:22 +03:00
fix: connection to db for heroku
This commit is contained in:
parent
6caec9beb3
commit
781b5aa157
@ -30,7 +30,7 @@ application.
|
||||
|
||||
- 1. Clone this repository `git clone https://github.com/sergeyyarkov/node-docker-example.git .`
|
||||
- 2. Configure enviroment variables in `docker-compose.yml` for `postgres` and `nodejs` serivces if you need to
|
||||
- 3. Build and run application with `docker compose up --build`
|
||||
- 3. Build and run application with `docker-compose up --build`
|
||||
|
||||
## Requirements
|
||||
|
||||
|
||||
10
db.js
10
db.js
@ -6,12 +6,14 @@ class Database {
|
||||
constructor() {
|
||||
this.client = new pg.Client({
|
||||
connectionString:
|
||||
process.env.NODE_ENV === 'production'
|
||||
process.env.NODE_ENV === 'production' && process.env.DATABASE_URL
|
||||
? process.env.DATABASE_URL
|
||||
: connectionString,
|
||||
ssl: {
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
ssl: process.env.DATABASE_URL
|
||||
? {
|
||||
rejectUnauthorized: false,
|
||||
}
|
||||
: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user