I am trying to Connect to my AWS RDS SQL Server DB using Nestjs i followed the documentation of nestjs and also some tutorials, but i keep getting the error when nestjs tries to connect to the Database. This is a fraction of my code where i establish the connection.
@Module({
imports: [
ConfigModule.forRoot({
envFilePath:'.env',
isGlobal: true
}),
TypeOrmModule.forRoot({
type: 'mssql',
host: 'xxx.xxxxxx.xxxxxx.rds.amazonaws.com',
port: 1433,
username: 'root',
password: 'root',
database: 'DB',
autoLoadEntities: true,
synchronize: true,
extra: {
trustServerCertificate: false,
Encrypt: true,
IntegratedSecurity: true,
}
}),
],
controllers: [AppController, EstadoProyController],
providers: [AppService],
})
export class AppModule {}
I would also like to add that i am able to log in directly via my SQL Server Management Studio using the Server name, user and password, but via NestJS i can't
i finally figured it out, to fix this problem i had to add this
ssl: true,
extra: {
trustServerCertificate: true,
Encrypt: true,
IntegratedSecurity: false,
}
you add this right after integrated synchronize: true
, as shown in my question above and it should work out