Fix postgres pg_hba.conf via docker-compose

This commit is contained in:
2026-08-11 12:51:18 +05:30
parent d264e3f1cc
commit cdd8deeef5
2 changed files with 11 additions and 13 deletions
+2 -13
View File
@@ -7,24 +7,13 @@ const app = express();
app.use(cors());
app.use(express.json());
const poolConfig = {
const pool = new Pool({
user: process.env.DB_USER || 'admin',
host: process.env.DB_HOST || 'localhost',
database: process.env.DB_NAME || 'sop_monitoring',
password: process.env.DB_PASS || 'password',
port: process.env.DB_PORT || 5432,
};
// If DB_SSL is true, or if we are connecting to an external host that likely requires SSL
if (process.env.DB_SSL === 'true' || (process.env.DB_HOST && process.env.DB_HOST !== 'db' && process.env.DB_HOST !== 'localhost')) {
poolConfig.ssl = { rejectUnauthorized: false };
} else {
// Try adding SSL unconditionally if it's rejecting without encryption
// Since we saw "pg_hba.conf rejects connection for host ... no encryption", it requires SSL.
poolConfig.ssl = { rejectUnauthorized: false };
}
const pool = new Pool(poolConfig);
});
app.get('/api/changeovers', async (req, res) => {
try {