Refactor database SSL configuration for improved clarity and flexibility
- Updated SSL settings in database.module.ts and ormconfig.ts to use DATABASE_SSL environment variable for better control over SSL usage. - Clarified comments to indicate that SSL is only necessary for remote PostgreSQL instances, enhancing understanding for local development setups.
This commit is contained in:
@@ -37,12 +37,11 @@ import { Unique } from './validators/unique.validator';
|
||||
query_timeout: 30_000,
|
||||
statement_timeout: 30_000,
|
||||
},
|
||||
// No SSL for local/Docker environments
|
||||
ssl:
|
||||
configService.get('ENVIRONMENT') === 'local' ||
|
||||
configService.get('ENVIRONMENT') === 'development'
|
||||
? false
|
||||
: { rejectUnauthorized: false },
|
||||
// SSL is only needed for remote/managed PostgreSQL (e.g. AWS RDS).
|
||||
// Self-hosted Docker setups use an internal network — no SSL required.
|
||||
ssl: configService.get('DATABASE_SSL') === 'true'
|
||||
? { rejectUnauthorized: false }
|
||||
: false,
|
||||
}),
|
||||
}),
|
||||
],
|
||||
|
||||
@@ -18,11 +18,9 @@ export default new DataSource({
|
||||
migrations: ['dist/database/migrations/*.{ts,js}'],
|
||||
migrationsTableName: 'typeorm_migrations',
|
||||
synchronize: false,
|
||||
ssl:
|
||||
configService.get('ENVIRONMENT') === 'local' ||
|
||||
configService.get('ENVIRONMENT') === 'development'
|
||||
? false
|
||||
: {
|
||||
rejectUnauthorized: false,
|
||||
},
|
||||
// SSL is only needed for remote/managed PostgreSQL (e.g. AWS RDS).
|
||||
// Self-hosted Docker setups use an internal network — no SSL required.
|
||||
ssl: configService.get('DATABASE_SSL') === 'true'
|
||||
? { rejectUnauthorized: false }
|
||||
: false,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user