Fix PostgreSQL SSL configuration for Azure
- Explicitly configure SSL in PostgresAdapter Pool - Always require SSL for Azure PostgreSQL connections - Add logging for database connection details
This commit is contained in:
@@ -30,10 +30,13 @@ export function createDatabaseAdapter(dbType?: string, dbPath?: string, allowClo
|
||||
const name = process.env.DATABASE_NAME || 'cmdb';
|
||||
const user = process.env.DATABASE_USER || 'cmdb';
|
||||
const password = process.env.DATABASE_PASSWORD || '';
|
||||
const ssl = process.env.DATABASE_SSL === 'true' ? '?sslmode=require' : '';
|
||||
// Azure PostgreSQL requires SSL - always use sslmode=require for Azure
|
||||
const isAzure = host.includes('.postgres.database.azure.com');
|
||||
const ssl = (process.env.DATABASE_SSL === 'true' || isAzure) ? '?sslmode=require' : '';
|
||||
|
||||
const constructedUrl = `postgresql://${user}:${password}@${host}:${port}/${name}${ssl}`;
|
||||
logger.info('Creating PostgreSQL adapter with constructed connection string');
|
||||
logger.info(`Database: ${name}, SSL: ${ssl ? 'required' : 'not required'}`);
|
||||
return new PostgresAdapter(constructedUrl, allowClose);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user