Skip to content

Commit 1461747

Browse files
Add debug log and default host for PostgreSQL client
Added debug log for PostgreSQL connection and default host.
1 parent 2086333 commit 1461747

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
const { Client } = require('pg');
22

33
exports.handler = async (event) => {
4-
// Create a NEW client inside handler
4+
// Force IPv4 for SSH tunnel
55
const client = new Client({
6-
host: process.env.DB_HOST,
6+
host: process.env.DB_HOST || '127.0.0.1', // default to 127.0.0.1
77
user: process.env.DB_USER,
88
password: process.env.DB_PASSWORD,
99
database: process.env.DB_NAME,
1010
port: 5432,
1111
ssl: { rejectUnauthorized: false } // IMPORTANT for RDS
1212
});
1313

14+
console.log('Connecting to PostgreSQL on host:', client.host); // debug log
15+
1416
await client.connect();
1517

1618
const method = event.httpMethod;

0 commit comments

Comments
 (0)