Question : Failed to connect to localhost:1433 - self signed certificate
Answered by : zany-zebra-m63s4myysj9a
const config = { port: parseInt(process.env.DB_PORT, 10), server: process.env.DB_HOST, user: process.env.DB_USER, password: process.env.DB_PASS, database: process.env.DB_Database, stream: false, options: { trustedConnection: true, encrypt: true, enableArithAbort: true, trustServerCertificate: false, },
}
sql.connect(config).then(pool => { if (pool.connecting) { console.log('Connecting to the database...') } if (pool.connected) { console.log('Connected to SQL Server') }
})
Source : https://stackoverflow.com/questions/60226370/certificate-error-when-connecting-to-sql-server | Last Update : Tue, 10 Aug 21