Improve database connection configuration and documentation for SSL
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
Update `docker-compose.yml` and `server/db.ts` to allow dynamic configuration of PostgreSQL SSL connections via the `DATABASE_SSL` environment variable. Add `DOCKER-DATABASE-SSL-GUIDE.md` detailing SSL options and troubleshooting. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ceced2fc-aa46-458d-ba87-ddd4b7bb1518 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/659922a9-0087-461c-90dd-6d9a58b81d4d/ceced2fc-aa46-458d-ba87-ddd4b7bb1518/flNt5I4
This commit is contained in:
+13
-3
@@ -15,11 +15,21 @@ export function getDatabase() {
|
||||
throw new Error('DATABASE_URL environment variable is not set');
|
||||
}
|
||||
|
||||
// Configure SSL based on DATABASE_SSL environment variable
|
||||
// Values: 'true', 'false', or 'require'
|
||||
// Default: false (no SSL)
|
||||
let sslConfig: any = false;
|
||||
|
||||
if (process.env.DATABASE_SSL === 'true') {
|
||||
sslConfig = { rejectUnauthorized: false }; // SSL with self-signed certs
|
||||
} else if (process.env.DATABASE_SSL === 'require') {
|
||||
sslConfig = { rejectUnauthorized: true }; // SSL with valid certs only
|
||||
}
|
||||
// Otherwise defaults to false (no SSL)
|
||||
|
||||
pool = new Pool({
|
||||
connectionString: databaseUrl,
|
||||
ssl: process.env.NODE_ENV === 'production'
|
||||
? { rejectUnauthorized: false } // Allow self-signed certificates in production
|
||||
: false, // No SSL in development
|
||||
ssl: sslConfig,
|
||||
});
|
||||
|
||||
db = drizzle(pool, { schema });
|
||||
|
||||
Reference in New Issue
Block a user