We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2086333 commit 1461747Copy full SHA for 1461747
index.js
@@ -1,16 +1,18 @@
1
const { Client } = require('pg');
2
3
exports.handler = async (event) => {
4
- // Create a NEW client inside handler
+ // Force IPv4 for SSH tunnel
5
const client = new Client({
6
- host: process.env.DB_HOST,
+ host: process.env.DB_HOST || '127.0.0.1', // default to 127.0.0.1
7
user: process.env.DB_USER,
8
password: process.env.DB_PASSWORD,
9
database: process.env.DB_NAME,
10
port: 5432,
11
ssl: { rejectUnauthorized: false } // IMPORTANT for RDS
12
});
13
14
+ console.log('Connecting to PostgreSQL on host:', client.host); // debug log
15
+
16
await client.connect();
17
18
const method = event.httpMethod;
0 commit comments